Skip to content

Add findings section to detectorTool#21

Merged
drdavella merged 2 commits intomainfrom
detector-findings
Mar 12, 2024
Merged

Add findings section to detectorTool#21
drdavella merged 2 commits intomainfrom
detector-findings

Conversation

@drdavella
Copy link
Copy Markdown
Member

A bit of a strawman so we can have a discussion about it. Also took @gilday's suggestion to nest the rule in a separate object.

@drdavella drdavella requested review from gilday and nahsra March 8, 2024 15:28
@drdavella drdavella force-pushed the detector-findings branch 3 times, most recently from 15ef3bc to c48da73 Compare March 8, 2024 15:35
@drdavella drdavella force-pushed the detector-findings branch from c48da73 to 9677ec6 Compare March 8, 2024 15:35
Comment thread codetf.schema.json
"type": "string",
"description": "The ID of the rule"
},
"name": {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can imagine also a web link to the rule definition.

I think the name and ID might be the same in some cases. For CodeQL, this is definitely the case. Is that okay?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think that's fine. This purpose is to enable us to be consistent with "Fixes rule from tool (id: )", but I don't think it's a problem if name == id.

Comment thread codetf.schema.json
"description": "Reason the finding was not fixed"
}
},
"additionalProperties": true,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this section, but it could be potentially massive. Scanners commonly find pathological conditions where they end up reporting 50,000 things. Is there anything we can/should do in the spec to protect ourselves from massive, redundant info?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can add a maxItems although it's incumbent upon the consumer to enforce that. Basically it would mean we'd ignore any results beyond maxItems.

Comment thread codetf.schema.json
"name": {
"type": "string",
"description": "The name of the rule"
},
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think description is too onerous to add for codemod authors. We should provide a link to their documentation, if they have one, and that's it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay that's fair. So optional ruleUrl or something similar?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think rule URL is needed and scratches this itch

Comment thread codetf.schema.json
},
"additionalProperties": true,
"required": ["guid", "fixed"],
"if": {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL you can have if statements in here

Comment thread codetf.schema.json Outdated
},
"description": {
"type": "string",
"description": "A description of the rule"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This raises internationalization concerns for me, but I already have those same concerns about other descriptions in CodeTF, so we're no worse off by adding this. 🙏🏻'ing that LLM can just do all the English -> SomethingElse translations.

Comment thread codetf.schema.json Outdated
Comment thread codetf.schema.json
Comment on lines +245 to +249
"if": {
"properties": {
"fixed": { "boolean": false }
},
"required": ["reason"]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fancy

Comment thread codetf.schema.json
"type": "string",
"description": "Short description of the tool vendor rule that detected the issue"
"findings": {
"type": "array",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the case where a codemod would have multiple findings for a single tool within a single change?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The detectionTool belongs to the result and not to the change so I think we can expect potentially multiple findings here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, I misread that.

I know it's not explicit in the data model, but to help with my understanding, what's the relationship that we expect between change and finding? Is it, every finding that has fixed: true has one or more changes ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think so. Would it make sense to include the same finding ID as an optional field of cange or changeSet as well?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll vote YAGNI for now but we can consider enriching the data model with that link later.

Comment thread codetf.schema.json
"type": "string",
"description": "ID of the tool vendor rule that detected the issue"
"rule": {
"$ref": "#/definitions/detector/rule",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kind of like the name detector. Consider chaining detectionTool to detector.

@drdavella drdavella requested a review from nahsra March 8, 2024 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants