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

Static analysis workflow checks not working #36

Open
nihaals opened this issue Mar 5, 2021 · 2 comments
Open

Static analysis workflow checks not working #36

nihaals opened this issue Mar 5, 2021 · 2 comments

Comments

@nihaals
Copy link
Member

nihaals commented Mar 5, 2021

Example of skipped checks

Checks

name: ESLint
if: github.event_name != 'pull_request' || (github.event_name == 'pull_request' && github.event.head.repo.fork)

name: CodeQL
if: github.event_name != 'pull_request' || (github.event_name == 'pull_request' && github.event.head.repo.fork && github.base_ref == 'master')

@with-heart
Copy link
Contributor

I'm not entirely sure I'm following this workflow, likely due to my unfamiliarity with CodeQL. What's the goal?

@nihaals
Copy link
Member Author

nihaals commented Mar 6, 2021

The actions/jobs themselves aren't too important (although knowing about code scanning is probably useful).

This workflow includes all the static analysis tools, mainly ones that output SARIF files that are uploaded to GitHub's code scanning (although I did try sourcegraph's LSIF but it was taking more work than it seemed to be worth).

name: CodeQL
if: github.event_name != 'pull_request' || (github.event_name == 'pull_request' && github.event.head.repo.fork && github.base_ref == 'master')

The CodeQL job essentially finds common web exploits and sends them to the code scanning tab. This isn't public but I'm not sure on the exact permission it's locked behind (I can't change repo settings but I still have access to it). My intention with the CodeQL check is "If it's a commit to this repo (not a fork), scan it. If not (therefore it must be a PR), make sure it's a PR where the source is a fork (prevents double scanning the same commit since otherwise commits to this repo would be scanned from both push and pull_request) and the target branch is master".

Scanning commits in this repo makes sense as they'll all eventually become a PR to master, so scanning them earlier with push just makes sense. Scanning PRs is slightly more complex though, but if we're merging a PR, it would be nice to know about issues before it's merged to master, not after. Filtering it to master is just because that's really the only important branch that needs this (a PR to another branch shouldn't impact prod so it's fine to scan it after it's merged). I think CodeQL will still run in the PR author's fork, it just won't show on ours.

name: ESLint
if: github.event_name != 'pull_request' || (github.event_name == 'pull_request' && github.event.head.repo.fork)

The ESLint job runs ESLint and sends the errors to code scanning. This gives something like:

image

While this is actually an example in the docs (suggesting code scanning is really for any static analysis tools), it being in the security tab and not being public makes it a bit weird. I think we should actually remove this in favour of running ESLint in standard CI, but maybe have in line annotations (example with codecov). I'm not sure if there is already a nice way of doing this but not just having a long list of errors but instead having it in the diff view is a nice way to actually see the issues. As ESLint will be mandatory (related: #33), this isn't a must, just a nice goal in the future if it's not easily doable.

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

No branches or pull requests

2 participants