Skip to content
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

Add support for Virus Total #3294

Merged
merged 20 commits into from
May 24, 2024
Merged

Add support for Virus Total #3294

merged 20 commits into from
May 24, 2024

Conversation

nvdaes
Copy link
Sponsor Contributor

@nvdaes nvdaes commented Apr 21, 2024

Issue number

Fixes issue #3246

Summary of the issue

VirusTotal may catch malware bundled with add-ons.
Also, knowing the sha256 of scanned add-ons, the URL to see results at different datetimes maybe built, allowing users to see this information even before installing an add-on if this was included in the NVDA store in the future.

Development strategy

  • Virus Total CLI is installed when needed.
  • Add-ons are scanned when the submission issue is created.
  • Info about the add-on file is requested to Virus Total later, when the pull request is created, to give time to Virus Total to show results, trying to avoid getting empty analysis.
  • NV Access needs to create an API key in Virus Total.
  • The addonMetadata.json artifact is used to get the add-on id and sha256.
  • A falsePositiveAddons.json file has been added. If VirusTotal analysis fails, a pull request will be created adding the sha256 of the addon to a list associated with the add-on ID, in the falsePositiveAddons.json file.
  • If VirusTotal should be skipped for this add-on, NV Access will merge the created pull request, delete the branch created for the submission (in the form submitterIssueNumber), and relabel the issue to trigger a new workflow.

Testing performed

  • Use the sha256 of a malicious add-on, simulating that this sha correspond to a non malicious add-on.
  • Use the real sha256 calculated for the same add-on.

nvdaes#1299

@nvdaes nvdaes marked this pull request as ready for review April 21, 2024 03:05
@nvdaes
Copy link
Sponsor Contributor Author

nvdaes commented Apr 21, 2024

@seanbudd,I think this is readyfor review.
Also, we may include the URL with Virus Totalresults in the NVDA store. If this is accepted,itmay be addressed in this pull request, adding a step to include the URL in add-on metadata.
NV Access may want to test sending to a private datastore a malicious add-on, after creating a secret with a Virus Total API key.

@seanbudd seanbudd changed the title Add support forVirus Total Add support for Virus Total Apr 22, 2024
.github/workflows/checkAndSubmitAddonMetadata.yml Outdated Show resolved Hide resolved
.github/workflows/checkAndSubmitAddonMetadata.yml Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
.github/workflows/sendJsonFile.yml Outdated Show resolved Hide resolved
.github/workflows/sendJsonFile.yml Outdated Show resolved Hide resolved
.github/workflows/checkAndSubmitAddonMetadata.yml Outdated Show resolved Hide resolved
.github/workflows/checkAndSubmitAddonMetadata.yml Outdated Show resolved Hide resolved
@seanbudd seanbudd marked this pull request as draft April 23, 2024 06:19
@seanbudd
Copy link
Member

I've created an API key now by the way

@nvdaes nvdaes marked this pull request as ready for review April 23, 2024 12:25
@XLTechie
Copy link
Contributor

XLTechie commented Apr 24, 2024 via email

@nvdaes
Copy link
Sponsor Contributor Author

nvdaes commented Apr 24, 2024

Luke wrote:

how long is the retention period?

By default, 90 days:

Configuring the retention period for GitHub Actions artifacts and logs in your organization .

What is the workflow going to show that will be helpful if the artifact is missing?

Just that it failed.

@XLTechie
Copy link
Contributor

XLTechie commented Apr 24, 2024 via email

@nvdaes
Copy link
Sponsor Contributor Author

nvdaes commented Apr 24, 2024

Luke Luke wrote:

If 90 days is the limit, then think we should have a cron-timed cleanup workflow that posts a comment and closes any open PRs/issues that failed their initial check.
Github already has a sample workflow for this, all we need to do is use it with a label for failed security checks. It will even post an appropriate comment.

If you can, please share the mentioned GitHub workflow.
Let's wait to see if NV Access accepts your proposal. For me it's reasonable.

@nvdaes
Copy link
Sponsor Contributor Author

nvdaes commented Apr 24, 2024

Also, note that, in this case, the artifact is generated even if VirusTotal doesn't flag an add-on as malicious, to see other results like Non detected, suspicious, etc.

@XLTechie
Copy link
Contributor

XLTechie commented Apr 24, 2024 via email

@XLTechie
Copy link
Contributor

XLTechie commented Apr 24, 2024 via email

@seanbudd
Copy link
Member

seanbudd commented May 8, 2024

Hi @nvdaes - I'm considering this blocked by #3397
Once that's resolved I think we can look at this again

@seanbudd seanbudd marked this pull request as draft May 8, 2024 05:18
@seanbudd
Copy link
Member

seanbudd commented May 8, 2024

@nvdaes - unrelated, but would you consider adding this for NVDA releases? right now we manually upload release builds (beta, rc, stable) to virus total. I think it would be worth also scanning alpha builds if we can do it automatically. Right now it will require some work to create an NVDA installer artifact to scan in GitHub Actions.

@XLTechie
Copy link
Contributor

XLTechie commented May 8, 2024 via email

@seanbudd
Copy link
Member

seanbudd commented May 8, 2024

@XLTechie - I think ideally compiling NVDA on GitHub actions, it would be a big step to help us migrate from appVeyor. But yes, we can also use a webhook to trigger the action

@nvdaes
Copy link
Sponsor Contributor Author

nvdaes commented May 8, 2024

About NVDA and VirusTotal, I used Appveyor years ago to manage add-ons, but I prefer GitHub Actions since it was simple for me, and I felt that the process to add projects to Appveyor was not very accessible and required to emulate a mouse click. So I haven't investigated about Appveyor from that time.
I have used GitHub Actions preparing NVDA source code to test add-ons. I can try to work trying to add VirusTotal scanning for NVDA artifacts with GitHub Actions.
If work should be done with Appveyor, I think that @perhaps @XLTechie can do it better than me.

@XLTechie
Copy link
Contributor

XLTechie commented May 8, 2024

@XLTechie - I think ideally compiling NVDA on GitHub actions, it would be a big step to help us migrate from appVeyor.

@seanbudd I wasn't aware that was a goal of NV Access. @LeonarddeR seems to think it's impractical (nvaccess/nvda#10516 (comment)), and the discussion is still closed on that subject.

@LeonarddeR
Copy link
Contributor

Interesting subject, I will update nvaccess/nvda#10516 with most recent findings.

@seanbudd
Copy link
Member

I've triaged nvaccess/nvda#10516 and added more information there . This PR should also be unblocked now.

@nvdaes
Copy link
Sponsor Contributor Author

nvdaes commented May 19, 2024

Note: The sha of the malicious add-on has been commented without removing it from the js file used for the VirusTotal analysis. Should we remove it?

@nvdaes nvdaes marked this pull request as ready for review May 19, 2024 06:07
@nvdaes nvdaes requested a review from seanbudd May 19, 2024 06:08
@nvdaes
Copy link
Sponsor Contributor Author

nvdaes commented May 20, 2024

@seanbudd I've addressed your review and checked that:

  1. If virusTotal and analysis fails, a PR with two files, falsePositiveAddons.json and reviewedAddons.json can be created:

nvdaes#1346

@nvdaes nvdaes marked this pull request as ready for review May 20, 2024 19:18
@nvdaes nvdaes requested a review from seanbudd May 20, 2024 19:18
@seanbudd
Copy link
Member

If virusTotal and analysis fails, a PR with two files, falsePositiveAddons.json and reviewedAddons.json can be created:

Can you please make this one file? There's no need to maintain two separate whitelists for add-ons

@nvdaes
Copy link
Sponsor Contributor Author

nvdaes commented May 21, 2024

If virusTotal and analysis fails, a PR with two files, falsePositiveAddons.json and reviewedAddons.json can be created:

Can you please make this one file? There's no need to maintain two separate whitelists for add-ons
OK.

@nvdaes
Copy link
Sponsor Contributor Author

nvdaes commented May 21, 2024

@seanbudd, now we use a file named reviewedAddons.json for CodeQL analysis and VirusTotal. After testing that the PR includes a unique file, I've set the overwrite for the manualApproval artifact in VirusTotal and in the CodeQL analysis. The sha256 will be the same, so in the real life this can be done.
See tests in nvdaes#1352

@seanbudd
Copy link
Member

This PR now contains a large number of files in addons/readFeeds

@nvdaes nvdaes marked this pull request as draft May 22, 2024 13:01
@nvdaes nvdaes marked this pull request as ready for review May 22, 2024 14:03
@nvdaes
Copy link
Sponsor Contributor Author

nvdaes commented May 22, 2024

Sorry. I test this creating or relabelling issues and making changes on the master branch of my fork, and sometimes changes are committed accidentally to this branch.
I think that now all maybe fixed. I've tested again the creation of the PR for manual approval.
See nvdaes#1361

.github/workflows/sendJsonFile.yml Outdated Show resolved Hide resolved
uses: ./.github/workflows/codeql-analysis.yml
createManualApproval:
needs: [getAddonId, virusTotal-analysis, codeQL-analysis]
if: ${{ always() && contains(join(needs.*.result, ','), 'failure') }}
Copy link
Member

Choose a reason for hiding this comment

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

will this will happen if getAddonId fails?

Copy link
Sponsor Contributor Author

Choose a reason for hiding this comment

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

No, since this needs codeQL-analysis and virusTotal-analysis, which need createPullRequest, which needs verifySubmitter, which won't be run if getAddonId fails.

.github/workflows/checkAndSubmitAddonMetadata.yml Outdated Show resolved Hide resolved
@seanbudd
Copy link
Member

thanks @nvdaes - this almost ready just one more question

@seanbudd seanbudd merged commit 313f6d0 into nvaccess:master May 24, 2024
@seanbudd
Copy link
Member

Thanks @nvdaes for all your efforts here!

@nvdaes
Copy link
Sponsor Contributor Author

nvdaes commented May 24, 2024

Thank you @seanbudd for your reviews. Testing has been hard, so thanks for your patience 😀

@nvdaes nvdaes mentioned this pull request May 25, 2024
seanbudd pushed a commit that referenced this pull request May 26, 2024
Summary of the issue
In #3294
, a workflow contains a non indentent body.
This bug has been reported by @josephsl and @mltony.
See issue #3633.

@josephsl has detected the exact bug.
Yo u may want to review this @josephsl.

Test
nvdaes/addon-datastore/actions/runs/9237486054

Note: I've exceeded my VirusTotal API key limit today, trying to analyze all add-ons of the store, but the workflow syntax should be fixed.
seanbudd added a commit that referenced this pull request May 27, 2024
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.

4 participants