-
-
Notifications
You must be signed in to change notification settings - Fork 18
Add support for PackageGuard and use it in the pipeline #659
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
Open
dennisdoomen
wants to merge
2
commits into
develop
Choose a base branch
from
claude/packageguard-generated-support-e39906
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,6 +34,7 @@ | |
| "GenerateTools", | ||
| "Install", | ||
| "Pack", | ||
| "PackageGuard", | ||
| "Publish", | ||
| "References", | ||
| "ReportCoverage", | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| # ------------------------------------------------------------------------------ | ||
| # <auto-generated> | ||
| # | ||
| # This code was generated. | ||
| # | ||
| # - To turn off auto-generation set: | ||
| # | ||
| # [GitHubActions (AutoGenerate = false)] | ||
| # | ||
| # - To trigger manual generation invoke: | ||
| # | ||
| # fallout --generate-configuration GitHubActions_security-scan --host GitHubActions | ||
| # | ||
| # </auto-generated> | ||
| # ------------------------------------------------------------------------------ | ||
|
|
||
| name: security-scan | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - develop | ||
| - main | ||
| - 'release/*' | ||
| - 'support/*' | ||
| paths-ignore: | ||
| - 'docs/**' | ||
| - '.assets/**' | ||
| - '**/*.md' | ||
|
|
||
| permissions: | ||
| security-events: write | ||
| contents: read | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| ubuntu-latest: | ||
| name: ubuntu-latest | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v7 | ||
| with: | ||
| fetch-depth: 0 | ||
| - name: 'Cache: .fallout/temp, ~/.nuget/packages' | ||
| uses: actions/cache@v6 | ||
| with: | ||
| path: | | ||
| .fallout/temp | ||
| ~/.nuget/packages | ||
| key: ${{ runner.os }}-${{ hashFiles('**/global.json', '**/*.csproj', '**/Directory.Packages.props') }} | ||
| - name: 'Setup: .NET SDK' | ||
| uses: actions/setup-dotnet@v6 | ||
| with: | ||
| global-json-file: global.json | ||
| - name: 'Restore: dotnet tools' | ||
| run: dotnet tool restore | ||
| - name: 'Run: PackageGuard' | ||
| run: dotnet fallout PackageGuard | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| - name: 'Upload risk-report SARIF to GitHub code scanning' | ||
| uses: github/codeql-action/upload-sarif@v3 | ||
| with: | ||
| sarif_file: output/packageguard/risk-report.sarif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| { | ||
| "Settings": { | ||
| "Allow": { | ||
| "Licenses": [ | ||
| "MIT", | ||
| "Apache-2.0", | ||
| "BSD-2-Clause", | ||
| "BSD-3-Clause", | ||
| "ISC", | ||
| "0BSD", | ||
| "MS-PL" | ||
| ], | ||
| // FluentAssertions and NetArchTest.Rules are MIT-licensed but don't publish a | ||
| // license expression/URL NuGet metadata can pick up. See #659. | ||
| "Packages": [ | ||
| "FluentAssertions", | ||
| "NetArchTest.Rules" | ||
| ] | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| using Fallout.Common; | ||
| using Fallout.Common.Git; | ||
| using Fallout.Common.IO; | ||
| using Fallout.Common.Tooling; | ||
| using Fallout.Common.Tools.PackageGuard; | ||
| using Fallout.Common.Utilities; | ||
| using Fallout.Components; | ||
|
|
||
| partial class Build | ||
| { | ||
| // PackageGuard's own CLI only exposes an env-var override for the risk-report path | ||
| // (see PackageGuard.json's help text on ReportRisk) — there's no `--report-risk <path>` | ||
| // argument in our wrapper, matching the repo-wide convention that bool CLI flags stay | ||
| // presence-only. Setting this process env var instead pins the SARIF/HTML pair to a | ||
| // deterministic path we can reference from CI (upload-sarif, the release asset step). | ||
| const string PackageGuardReportRiskPathOverrideEnvironmentVariable = "PACKAGEGUARD_REPORT_RISK_PATH_OVERRIDE"; | ||
|
|
||
| AbsolutePath PackageGuardDirectory => OutputDirectory / "packageguard"; | ||
| AbsolutePath PackageGuardSbomFile => PackageGuardDirectory / "sbom.json"; | ||
| AbsolutePath PackageGuardSarifFile => PackageGuardDirectory / "risk-report.sarif"; | ||
|
|
||
| // The SBOM and risk report (HTML + SARIF) are only worth generating where they're actually | ||
| // consumed: security-scan.yml uploads the SARIF on a push to one of these four branches, and | ||
| // the release workflow attaches the SBOM/HTML to the GitHub Release. Neither happens on a PR | ||
| // (build.yml checks out the contributor's own branch via github.head_ref, never one of | ||
| // these), or on a tag-triggered release checkout (detached HEAD — hence the | ||
| // GitHubActions.Workflow fallback, since that workflow's own validate-ref job already | ||
| // proved the tag is reachable from a production branch). | ||
| bool IsOnLongLivedBranch => | ||
| GitRepository.IsOnMainBranch() || | ||
| GitRepository.IsOnDevelopBranch() || | ||
| GitRepository.IsOnReleaseBranch() || | ||
| GitRepository.IsOnSupportBranch() || | ||
| GitHubActions?.Workflow == ReleaseWorkflow; | ||
|
|
||
| // Runs unconditionally — this is the PR gate's policy-violation check (build.yml), so it has | ||
| // to run on every branch, including a contributor's feature branch. Only the SBOM/risk-report | ||
| // generation is restricted to the four long-lived branches, via IsOnLongLivedBranch below. | ||
| Target PackageGuard => _ => _ | ||
| .DependsOn<IRestore>() | ||
| .Produces(PackageGuardSbomFile) | ||
| .Produces(PackageGuardSarifFile) | ||
| .Produces(PackageGuardDirectory / "*.html") | ||
| .Executes(() => | ||
| { | ||
| var generateReports = IsOnLongLivedBranch; | ||
|
|
||
| if (generateReports) | ||
| PackageGuardDirectory.CreateOrCleanDirectory(); | ||
|
|
||
| PackageGuardTasks.PackageGuard(_ => _ | ||
| .SetProjectPath(Solution.Path) | ||
| .SetGitHubApiKey(From<ICreateGitHubRelease>().GitHubToken) | ||
| .When(generateReports, _ => _ | ||
| .EnableReportRisk() | ||
| .SetSbom(SbomFormat.cyclonedx) | ||
| .SetSbomOutput(PackageGuardSbomFile) | ||
| .SetProcessEnvironmentVariable(PackageGuardReportRiskPathOverrideEnvironmentVariable, PackageGuardSarifFile))); | ||
| }); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
tempted to swap netarch for archunit anyway but good to know 😬