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

Run SAST checks in CI #7674

Closed
wants to merge 6 commits into from
Closed

Run SAST checks in CI #7674

wants to merge 6 commits into from

Conversation

matmair
Copy link
Member

@matmair matmair commented Jul 17, 2024

We are currently failing the SAST section of https://securityscorecards.dev/viewer/?uri=github.com/inventree/InvenTree because it seems like SonarCloud is not running on (all?) PRs. The easiest solution for this is to just run it in CI, this should also help to discover problematic code sooner.

This PR:

  • adds a workflow to run sonar's checks on master and pull requests
  • adds the minimal config required for running sonar in CI

@matmair matmair added the CI CI / unit testing ecosystem label Jul 17, 2024
@matmair matmair added this to the 0.16.0 milestone Jul 17, 2024
@matmair matmair self-assigned this Jul 17, 2024
Copy link

netlify bot commented Jul 17, 2024

Deploy Preview for inventree-web-pui-preview canceled.

Name Link
🔨 Latest commit 38ed16c
🔍 Latest deploy log https://app.netlify.com/sites/inventree-web-pui-preview/deploys/6698f0b8917dad0008b3c15f

@matmair
Copy link
Member Author

matmair commented Jul 17, 2024

This will require the enviroment variable SONAR_TOKEN to be set - will be provided on another channel

uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
Copy link
Contributor

Choose a reason for hiding this comment

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

Q: when should this workflow execute? Are you aware, that this secret is never available with the pull_request trigger, due to protection mechanisms?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is 1:1 from the docs of SonarCloud, I trust that they validated this approach
https://github.com/SonarSource/sonarcloud-github-action?tab=readme-ov-file#usage

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, interesting, GitHub itself tells something else, but happy to have learned something new.

@SchrodingersGat
Copy link
Member

@matmair SONAR_TOKEN has now been added

@matmair
Copy link
Member Author

matmair commented Jul 24, 2024

Sonar / @agigleux have fixed the underlying issue, this is not needed anymore.

@SchrodingersGat you can remove the secret SONAR_TOKEN, it will not be needed

@matmair matmair closed this Jul 24, 2024
@matmair matmair deleted the sast-ci branch July 24, 2024 11:23
@SchrodingersGat
Copy link
Member

Awesome, thanks @agigleux and Sonar!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI CI / unit testing ecosystem
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants