Skip to content

Add check for id property when running variant analysis#3414

Merged
koesie10 merged 3 commits intomainfrom
koesie10/verify-valid-sarif
Mar 1, 2024
Merged

Add check for id property when running variant analysis#3414
koesie10 merged 3 commits intomainfrom
koesie10/verify-valid-sarif

Conversation

@koesie10
Copy link
Copy Markdown
Member

This adds a check for variant analyses to ensure that the @id metadata is set when running a problem or path-problem query. This will ensure that this error is caught early.

Checklist

  • CHANGELOG.md has been updated to incorporate all user visible changes made by this pull request.
  • Issues have been created for any UI or other user-facing changes made by this pull request.
  • [Maintainers only] If this pull request makes user-facing changes that require documentation changes, open a corresponding docs pull request in the github/codeql repo and add the ready-for-doc-review label there.

@koesie10 koesie10 marked this pull request as ready for review February 28, 2024 12:51
@koesie10 koesie10 requested a review from a team as a code owner February 28, 2024 12:51
// It's not possible to interpret a BQRS file to SARIF without an id property.
if (
queryMetadata?.kind &&
["problem", "path-problem"].includes(queryMetadata.kind) &&
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.

Should we also include alert and path-alert in this list?

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.

Yes, good point. I've changed this to use a function instead and also used this function in other places where I could find path-problem.

@koesie10 koesie10 requested a review from a team as a code owner February 29, 2024 13:02
Copy link
Copy Markdown
Contributor

@robertbrignull robertbrignull left a comment

Choose a reason for hiding this comment

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

LGTM

This can technically change behaviour in a couple of places, but it's very minor and I think it's fine and it's only making us more correct and consistent overall.

queryMetadata.kind === "problem" ||
queryMetadata.kind === "path-problem"
) {
if (isSarifResultsQueryKind(queryMetadata.kind)) {
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 shouldn't change behaviour since all queries in the published packs should be using the new query kinds. Also it should be safe anyway and more correct than it was before.

variantAnalysisQueryKind === "problem" ||
variantAnalysisQueryKind === "path-problem"
);
return isSarifResultsQueryKind(variantAnalysisQueryKind);
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.

It's possible that this could cause a tiny UI inconsistency until https://github.com/github/codeql-variant-analysis-action/blob/4a8a27800b99bca0d1900c940648b70243804e2f/src/codeql.ts#L351 is also updated. This is because we decide to show the column based on the query kind instead of whether there are SARIF results available, because we can't check every repo and we need to show the column before any repos have been analysed.

However, I think it's fine to merge this as it's highly unlikely to affect anybody and it's fine so long as we also update the variant analysis action soon.

@koesie10 koesie10 merged commit b7be98b into main Mar 1, 2024
@koesie10 koesie10 deleted the koesie10/verify-valid-sarif branch March 1, 2024 10:20
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.

2 participants