GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Produce separate SARIF file for `quality-queries` alerts by mbg · Pull Request #2935 · github/codeql-action

Conversation

@mbg

@mbg mbg commented Jun 16, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Follows on from #2917.

This PR modifies the action to produce separate SARIF files for code quality queries (as specified as arguments to the quality-queries input) and uploads them to the code quality API. The approach here is that:

  • We remove the logic from Add new quality-queries input #2917 that adds the quality-queries input to the code scanning configuration file that's used when initialising the database.
  • That means that the quality queries are no longer included in the config-queries.qls that's generated by the CLI.
  • When we call database run-queries, and if quality queries are enabled, we explicitly specify config-queries.qls (which the CLI normally does by default if nothing is specified) + the quality queries.
  • Since the quality queries are only specified as argument to database run-queries, the existing call to database interpret-results generates a SARIF that only includes results relating to security queries (i.e. config-queries.qls).
  • We make an additional call to database interpret-results for queries that were specified as arguments to the quality-queries input (if any). This results in SARIF files for those queries.
  • We then upload them to the CQ API endpoint.

Notes

  • The changes aim to be as backwards-compatible as possible. That includes:
    • SARIF files are output to the same place as before (e.g. as opposed to having separate subdirectories for security and quality SARIFs). SARIF files containing quality results are identified by the .quality.sarif extension.
  • We don't support query-filter options with respect to code quality results.

Merge / deployment checklist

  • Confirm this change is backwards compatible with existing workflows.
  • Confirm the readme has been updated if necessary.
  • Confirm the changelog has been updated if necessary.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@mbg
mbg force-pushed the mbg/interpret-cq-results branch 2 times, most recently from 87b6687 to fe76653 Compare June 17, 2025 13:37
github-advanced-security[bot]
github-advanced-security AI found potential problems Jun 17, 2025
View reviewed changes
Comment thread src/upload-lib.ts Fixed

Uh oh!

There was an error while loading. Please reload this page.

mbg added 8 commits June 23, 2025 18:19
@mbg
Interpret results for quality queries and store as separate SARIF file
3963bf4
@mbg
Upload both SARIF files in quality-queries check
aba8788
@mbg
Check SARIF with quality results for expected configuration
3a7544e
@mbg
Resolve code-quality alias
320f7b0
@mbg
Add ability to use different filters in findSarifFilesInDir
22444a6
@mbg
Upload quality SARIFs to CQ endpoint
45b3bec
@mbg
Allow the same category once for each type of upload
f183422
@mbg
Fix getSarifFilePaths not using right filter
6abacdb
@mbg
mbg force-pushed the mbg/interpret-cq-results branch from 2bf7322 to 24e4f58 Compare June 23, 2025 17:35
@mbg
Support all default query suites and resolve them
f7fbaa0
@mbg
mbg force-pushed the mbg/interpret-cq-results branch from 7e59f77 to f7fbaa0 Compare June 24, 2025 12:09
mbg added 4 commits June 24, 2025 13:24
@mbg
Add test for modified findSarifFilesInDir
5189159
@mbg
Add test for modified validateUniqueCategory
af32bc6
@mbg
Add test for resolveQuerySuiteAlias
9b9286a
@mbg
Add some more comments
86f47e8
@mbg
mbg marked this pull request as ready for review June 24, 2025 13:08
@mbg
mbg requested a review from a team as a code owner June 24, 2025 13:08
@mbg
mbg requested a review from Copilot June 24, 2025 13:09
Copilot AI reviewed Jun 24, 2025
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enables separate generation and upload of SARIF files for code-quality queries specified via the quality-queries input, in addition to the existing code-scanning SARIF flow.

  • Introduces SARIF_UPLOAD_TARGET enum and UploadTarget interface to distinguish code scanning vs. code quality uploads.
  • Extends file discovery (findSarifFilesInDir, getSarifFilePaths) and upload logic (uploadFiles, uploadPayload, validateUniqueCategory) to filter and handle .quality.sarif files.
  • Updates analyze.ts/analyze-action.ts to produce and upload quality SARIFs when quality-queries are provided, and adjusts CI workflows to upload/check both SARIF artifacts.

Reviewed Changes

Copilot reviewed 12 out of 17 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/upload-lib.ts Added enum and targets for separate SARIF uploads, filtering logic for .quality.sarif.
src/upload-lib.test.ts Added tests for filtering .quality.sarif files and validateUniqueCategory prefix.
src/analyze.ts Introduced default query suites and resolveQuerySuiteAlias; generate quality SARIF.
src/analyze.test.ts Added tests for resolveQuerySuiteAlias.
src/analyze-action.ts Uploads quality SARIF and sets quality-sarif-id output when quality-queries present.
pr-checks/checks/quality-queries.yml CI updates to upload security vs. quality SARIF artifacts and adjust checks.
Comments suppressed due to low confidence (2)

src/upload-lib.ts:427

  • The getSarifFilePaths function bypasses the isSarif filter when sarifPath is a single file. This can lead to uploading unwanted files (e.g., a .quality.sarif when targeting code-scanning). Apply isSarif to the single-file case or throw if it does not match.
    sarifFiles = [sarifPath];

pr-checks/checks/quality-queries.yml:29

  • [nitpick] The CI step now only checks config properties in the quality SARIF, omitting the original security SARIF check. Consider adding a separate check for ${{ runner.temp }}/results/javascript.sarif to ensure both artifacts are validated.
      SARIF_PATH: "${{ runner.temp }}/results/javascript.quality.sarif"

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@mbg
Upload .quality.sarif files to CQ service in upload-sarif action
2c76207
@mbg
mbg force-pushed the mbg/interpret-cq-results branch 2 times, most recently from 3393b4e to 81969d7 Compare June 25, 2025 13:24
@mbg
Prototyping adding quality queries when running queries
e382508
@mbg
mbg force-pushed the mbg/interpret-cq-results branch 2 times, most recently from 4088317 to b403ba2 Compare June 25, 2025 13:38
@mbg
Fix config-queries.qls location
79049d9
@mbg
mbg force-pushed the mbg/interpret-cq-results branch from b403ba2 to 79049d9 Compare June 25, 2025 13:42
esbena
esbena reviewed Jun 25, 2025
View reviewed changes

@esbena esbena left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Nice, and pleasantly surgical.

I think this does the right thing, except for a missing quality.sarif predicate in the very end.

Other than that it's mostly nits, and some concerns about maintenance in the long term. We have already discussed them elsewhere. Perhaps we should update the discussion document with our current choice for query resolution.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/analyze.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/analyze.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/codeql.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/upload-lib.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/upload-lib.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/upload-lib.ts
}

// Represents configurations for different services that we can upload SARIF to.
export interface UploadTarget {

@esbena esbena Jun 25, 2025

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

regarding the target/endpoint comment above: this is a much better place to call something target. I'd probably prefer SarifUploadConfig but that is splitting hairs.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/upload-lib.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/upload-lib.ts
sentinelPrefix: string;
}

// Represents the Code Scanning upload target.

@esbena esbena Jun 25, 2025

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Stray thought. I have seen both line comments and jsdoc comments on your new functions. Is it deliberate that you do not use jsdoc here? If yes, OK.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@mbg mbg Jun 26, 2025

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I think the existing codebase is fairly inconsistent in this regard. I probably just subconsciously mirrored what adjacent definitions do. I'll make this more consistent for my changes.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/upload-sarif-action.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/upload-lib.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

mbg added 6 commits June 26, 2025 11:32
@mbg
Rename resolveQuerySuiteAlias parameter
768fc17
@mbg
Document queries parameter for databaseRunQueries
27db6cb
@mbg
Rename SARIF_UPLOAD_TARGET
71dd633
@mbg
Move .sarif predicates into UploadTarget instances and rename
08955db
@mbg
Fix incorrect getSarifFilePaths call in upload-sarif action
9ec0bb9
@mbg
Avoid default arguments with historical values
ad6046f
@mbg mbg mentioned this pull request Jun 26, 2025
Remove quality results from security SARIF #2949
Closed
3 tasks
mbg added 4 commits June 27, 2025 12:08
@mbg
Use findSarifFilesInDir in upload-sarif to avoid error when there…
7b3d150
… are no `quality.sarif` files
@mbg
Add test workflow for upload-sarif with quality results
3e95091
@mbg
Fix formatting
10a3e4b
@mbg
Check both SARIF files in quality-queries.yml test
362ebf8
@mbg
mbg force-pushed the mbg/interpret-cq-results branch from a4d5138 to 362ebf8 Compare June 27, 2025 11:33
@mbg
mbg requested a review from esbena June 27, 2025 11:42
esbena
esbena previously approved these changes Jun 27, 2025
View reviewed changes

@esbena esbena left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

thanks! There's one naming nit left, but it is quite minor.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/upload-lib.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

@mbg
Rename SARIF_UPLOAD_ENDPOINT members
65d1e45
@mbg
mbg dismissed esbena’s stale review via 65d1e45 June 27, 2025 12:45
mbg added 2 commits June 27, 2025 13:45
@mbg
Merge branch 'main' into mbg/interpret-cq-results
aa72dda
@mbg
Add changelog entry
2830b75
@mbg
mbg requested a review from esbena June 27, 2025 12:50
esbena
esbena approved these changes Jun 27, 2025
View reviewed changes
@mbg
mbg enabled auto-merge June 27, 2025 12:51
@mbg
mbg merged commit 4c57370 into main Jun 27, 2025
@mbg
mbg deleted the mbg/interpret-cq-results branch June 27, 2025 13:03
@github-actions github-actions Bot mentioned this pull request Jun 30, 2025
Merge main into releases/v3 #2957
Merged
6 of 8 tasks
@jsoref

jsoref commented Jul 6, 2025

Copy link
Copy Markdown
Contributor

This appears to talk about another github api endpoint. Is it documented / will it be documented?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mbg

mbg commented Jul 7, 2025

Copy link
Copy Markdown
Member Author

@jsoref It is not documented. This is part of an internal experiment and so is no use to anyone but us right now.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This was referenced Aug 5, 2025
Overlay: check query packs for compatibility #2993
Merged
Fix upload-sarif potentially initialising CodeQL twice #3006
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Copilot code review Copilot
Copilot review effort
Applies to this pull request for everyone.Learn more about Copilot code review.
Copilot left review comments
@esbena esbena esbena approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@mbg @jsoref @esbena @github-advanced-security
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.