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

Update to add devskim #83

Closed
wants to merge 6 commits into from
Closed

Update to add devskim #83

wants to merge 6 commits into from

Conversation

rjmurillo
Copy link
Owner

@rjmurillo rjmurillo commented Jun 12, 2024

Adds DevSkim rules to check for correctness and security

  • Added as a task on the Linux builder (task only supports Linux) that scans as part of the build. Build is run periodically so we would get new notifications if something gets flagged.
  • Added code analysis package so developers are warned as they're writing code of DevSkim issues. This prevents new changes from getting committed to source and shifts left detection to code author time, rather than CI time.

@github-advanced-security
Copy link

This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation.

DevSkim is only supported on Linux OS
@rjmurillo rjmurillo added this to the vNext milestone Jun 12, 2024
@rjmurillo rjmurillo marked this pull request as ready for review June 12, 2024 18:52
@rjmurillo rjmurillo requested a review from MattKotsenas June 12, 2024 18:56
@rjmurillo rjmurillo enabled auto-merge (squash) June 12, 2024 18:57
@@ -104,3 +104,13 @@ jobs:
uses: github/codeql-action/analyze@v3
with:
category: "/language:csharp"

- name: Run DevSkim scanner
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't like that there isn't a simple way to repro issues locally. Can we integrate it in some way to make local dev work as well?

Good

  • Add to dotnet tools
  • Add dotnet tool restore to YAML (sorry, I thought I added it already)
  • Add basic pwsh script to run devskim

Better

  • Same as above, but integrate into MSBuild via Exec or similar

Copy link
Collaborator

Choose a reason for hiding this comment

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

That would also avoid the linux-only issue the GitHub Action has

Copy link
Owner Author

Choose a reason for hiding this comment

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

There's a package we can integrate https://www.nuget.org/packages/Microsoft.CST.DevSkim/

Copy link
Owner Author

Choose a reason for hiding this comment

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

That would also avoid the linux-only issue the GitHub Action has

I'm already over the Windows builder. It's. So. Slow.

Zootopia slow sloth stamp

Copy link
Owner Author

Choose a reason for hiding this comment

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

@MattKotsenas Updated to also include the CA rules, so it's a "yes, and"

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think that package is just a lib though: https://nuget.info/packages/Microsoft.CST.DevSkim/1.0.33 so I'm not sure how to drive it from that package. Haven't looked much though so go for it.

Copy link
Owner Author

@rjmurillo rjmurillo Jun 12, 2024

Choose a reason for hiding this comment

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

Can't use it anyway, doesn't support netstandard 2.0 (only 2.1). I'll go the global tool route so we have something. There's also a VSIX and VSCode extension, but I don't like that for various reasons.

Copy link
Owner Author

Choose a reason for hiding this comment

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

@MattKotsenas we're going hold off on this. I've raised two issues with DevSkim, microsoft/DevSkim#619 and microsoft/DevSkim#618 to address the issues. 619 is the one I want, so it's super consistent with everything else and "just works"

Copy link
Owner Author

Choose a reason for hiding this comment

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

Update: The "Good" or "Better" options above are the resolution to microsoft/DevSkim#618

It seems that a Dockerfile defined action (as DevSkim-Action is) is restricted to Linux pipelines only - the workaround seems to be to migrate to a Typescript action. I found a similar issue reported in another repo on GitHub with the same conclusion - peter-evans/create-pull-request#40. For us, the workaround is a little undesirable here - the docker method allows us to ensure that the .NET SDK is available and pull the latest version of the DevSkim tool, without interfering with the users environment, and ultimately the equivalent behavior of the action is only a couple lines of YML.

Link: microsoft/DevSkim#618 (comment)

I think I'm going to abandon this until microsoft/DevSkim#619 is implemented. Right now all the rules are RegEx so the perf is 1) not good, and 2) not always attached to a symbol. There will need to be some reworking on their end to get this to work as a proper analyzer.

What we're missing out on doesn't seem too critical for this project. Lots of making sure you're not doing silly things like disabling HTTPS checks, making sure you use secure URIs, not using weak crypto algos, vulnerable NuGet packages, and so on. Some of those are covered already by other analyzers (built in or otherwise).

@rjmurillo rjmurillo changed the title Update main.yml to add devskim Update to add devskim Jun 12, 2024
@rjmurillo rjmurillo marked this pull request as draft June 12, 2024 20:59
auto-merge was automatically disabled June 12, 2024 20:59

Pull request was converted to draft

@rjmurillo rjmurillo closed this Jun 14, 2024
@github-actions github-actions bot added the github_actions Pull requests that update GitHub Actions code label Jun 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
github_actions Pull requests that update GitHub Actions code housekeeping
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants