-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create manual approval process for errors with code scanned add-ons #3397
Conversation
- name: Download add-on again | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: addon |
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.
why does this download need to happen again?
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.
The download has to be performed again since the add-on has been moved to a zip file and then expanded, so the addon.nvda-addon file is not present..
I'll address this review ASAP, but perhaps it won't be finished today, in case you want this to be fixed quickly, feel free to do it yourself.
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.
Instead can you make a copy rather than rename the zip file?
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.
Done
if: failure() | ||
uses: peter-evans/create-pull-request@v6 | ||
with: | ||
add-paths: trustedAddons.json |
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.
add-paths: trustedAddons.json | |
add-paths: reviewedAddons.json |
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.
So, given your other comment, this would be something like:
add-paths: trustedAddons.json | |
add-paths: overriddenFalsePositives.json |
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 that reviewed is more precisse than false positive, since codeQL, imo, is not detecting false positive but just errors in code, that may or not be related to security issues in the context of the whole add-on. I think that this is not the same as flagging an add-on as containing malicious contents. It's analyzing just source code. Anyway I'm not a native english speaker, but for Spanish, imo reviewed is a more accurate word for CodeQL.
const contents = fs.readFileSync(path); | ||
const data = JSON.parse(contents); | ||
const runs = data.runs[0]; | ||
const results = runs.results; | ||
if (results.length === 0) { | ||
core.info("Security analysis succeeded"); | ||
} else { | ||
trustedAddonsData.trustedAddons.push(hex); | ||
const stringified = JSON.stringify(trustedAddonsData, null, 2); |
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.
for submitters.json, we add a comment noting the author name.
Can you do something similar for adding a comment referencing the add-on id? Perhaps these should be grouped by add-on id.
@@ -1,12 +1,27 @@ | |||
module.exports = ({core}, path) => { | |||
module.exports = ({github, core}, path) => { |
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.
Could we change the framing for this to "Reviewed" add-on. I think "trusted" has too may implications
Security analysis has failed for this add-on. | ||
[See GitHub workflow](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) | ||
Please, contact NV Access for more details. |
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.
please update this message
- add a reference to the submitters guide: https://github.com/nvaccess/addon-datastore/blob/master/docs/submitters/submissionGuide.md
- copy in this information directly: "You can open this link and download artifacts containing the results of the analysis. Unzip artifacts and open the .sarif file in your preferred editor. For example, you can use Microsoft's Sarif web based reader. NV Access will determine whether or not the detection should prevent the add-on from being accepted. Please review the warnings and consider whether you want to fix this in the add-on. If you can provide more context on the failure in the submission, please do."
- note that the issue should be kept open
- note the PR reference created that needs to be merged, like the submitters.json message
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.
Did we resolve the question of why we weren't linking directly to the .sarif file instead? Even if it expires in 90 days, that is far preferable IMO.
I linked to an action for closing submission issues with a check failed label after 90 days, and would be happy to do a PR for same if @nvdaes doesn't want to.
Is it possible to only block CodeQL if the error severity is critical or above? |
@seanbudd You have made several suggestions here, replacing "trusted" with "reviewed".
I think the word "review"/"reviewed", is too overloaded.
We now use it for add-on reviews by the public, and there may be need to track things related to that in the future.
Additionally, it had other meanings in the past, that the community still knows.
I request some other word.
Perhaps "overridden"?
Or "manualSecCheck" or some such?
|
Maybe "overrideFalsePositive" to be the most specific |
if: failure() | ||
uses: peter-evans/create-pull-request@v6 | ||
with: | ||
add-paths: trustedAddons.json |
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.
So, given your other comment, this would be something like:
add-paths: trustedAddons.json | |
add-paths: overriddenFalsePositives.json |
I've created an artifact with the submitted json add-on metadata, checking out the created branch. This is uploaded as an artifact and it should be downloaded by the codeQL job, to get the addonId and sha256. |
Thanks for all your hard work, @nvdaes!
|
Co-authored-by: Sean Budd <seanbudd123@gmail.com>
…xist in the workflow
Sean wrote:
Using CodeQL action, we may configure filters to include and exclude. |
I think this is almost working, but two comments are added by the bot on failures. |
I've tested that add-ons can be submit after closing in quotes the step to validate submissions, to accept ids with spaces, in https://github.com/nvdaes/addon-datastore/actions/runs/9036423367/job/24833330757 This add-on doesn't have spaces in ids, but this should work if some add-ons uses this. |
Sean wrote:
I'll try to address this in this PR with another commit, blocking errors but not warnings. Seems that some add-ons were blocked due to warnings. |
My idea was to create two jobs, the first using a configuration file to exclude warnings, which would create a PR commenting on the submission issue.
|
Finally I've made a last commit to accept add-ons with CodeQL warnings, just reporting this to authors. https://github.com/nvdaes/addon-datastore/actions/runs/9041653622 |
Note that you may need to enable advanced setup for CodeQL. When you do it, a new workflow will be shown. Now it's used but it's hidden, and it needs to be edited to be shown. Later I have removed the edition, but I have advanced setup configured and my approach seems to be working. |
jobs: | ||
analyzeExcludingWarnings: | ||
name: Analyze add-on excluding warnings |
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 can't seem to find where warnings are excluded, can you point to this?
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.
Warnings are excluded via a configuration file including filters to exclude warnings and recommendation. I read that this would show just important errors, and I checked that it's the case for the readFeeds add-on. Also MathCAT was rejected just for warnings.
Warnings are excluded in the first job, which will fail just for important errors.
If this job fails, the second one won't be run and the PR will be created.
If the first job doesn't fail, the second job will search for warnings (less important errors), and these will be reported to authors without creating the PR to add this to reviewedAddons.
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.
Where is this configuration file? can it be documented here please
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.
It's in the .github/codeql subfolder. It contains two configuration files, one to exclude warnings ant the other one to include them. The init action determines which configuration file should be used for each job.
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.
These files appear to have not been committed to this PR.
The file on master doesn't contain anything relevant:
https://github.com/nvaccess/addon-datastore/blob/master/.github/codeql/codeql-config.yml
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.
Sorry, I tested all in my master branch and files were there.
I've also documented the config files in the development strategy. |
I've perform test in:
I've used this example: https://codeql.github.com/codeql-query-help/python/py-clear-text-logging-sensitive-data/ I suppose that more suites can be added in the CodeQL settings file (advanced settings of the repo), to determine what will be considered an error or a warning.
|
I think we're going throught the right way. I've excluded just low security severity for testing, and this PR has been created, with the addonId Also, I haven't need to use the configuration workflow of advanced settings. In fact I've removed it. |
For reference, I'm selecting 9-10 security severity levels based on this document: |
Test for showing warnings merging the PR: See the last comment on the issue. |
@seanbudd , I think this is ready for review. |
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 @nvdaes
Issue number
Fixes issue #3279
Summary of the issue
When security analysis fails for an add-on, if the created pull request is merged manually, review comment and transform Actions aren't performed.
Development strategy
Testing performed