Repository navigation
ci: prepare DLL Pickle for offline OSS Scanner analysis #319
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
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,89 @@ | ||
| name: OSS Scanner environment | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| ref: | ||
| description: Exact source reference supplied by the calling build workflow | ||
| required: true | ||
| type: string | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| offline-tests: | ||
| name: Build and test without network | ||
| runs-on: ubuntu-24.04 | ||
| timeout-minutes: 60 | ||
| steps: | ||
| - name: Check out source without persisted credentials | ||
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | ||
| with: | ||
| ref: ${{ inputs.ref || github.ref }} | ||
| persist-credentials: false | ||
|
|
||
| - name: Build scanner image | ||
| shell: bash | ||
| run: | | ||
| set -euo pipefail | ||
| mkdir -p "$RUNNER_TEMP/oss-scanner-evidence" | ||
| git rev-parse HEAD > "$RUNNER_TEMP/oss-scanner-evidence/source-commit.txt" | ||
| timeout 45m docker build --progress=plain -f .oss-scanner/Dockerfile \ | ||
| -t dllpickle-oss-scanner:test . 2>&1 | tee "$RUNNER_TEMP/oss-scanner-evidence/build.log" | ||
| docker image inspect dllpickle-oss-scanner:test \ | ||
| > "$RUNNER_TEMP/oss-scanner-evidence/image.json" | ||
|
|
||
| - name: Verify root tooling can inspect the source worktree | ||
| shell: bash | ||
| run: | | ||
| set -euo pipefail | ||
| docker run --rm --network none --user 0 --env HOME=/root \ | ||
| dllpickle-oss-scanner:test bash -c ' | ||
| set -euo pipefail | ||
| test "$(git config --global --get-all safe.directory)" = /src | ||
| git init -q /src | ||
| git -C /src status --porcelain > /dev/null | ||
| git -C /src diff --exit-code | ||
| git -C /src diff --cached --exit-code | ||
| echo "Root Git inspection passed with trust limited to /src." | ||
| ' 2>&1 | tee "$RUNNER_TEMP/oss-scanner-evidence/root-git.log" | ||
|
|
||
| - name: Rebuild and test with networking disabled | ||
| shell: bash | ||
| run: | | ||
| set -euo pipefail | ||
| evidence="$RUNNER_TEMP/oss-scanner-evidence" | ||
| docker create --name dllpickle-offline --network none --cpus 2 --memory 8g \ | ||
| dllpickle-oss-scanner:test pwsh -NoLogo -NoProfile -NonInteractive \ | ||
| -File .oss-scanner/test.ps1 | ||
| docker inspect --format '{{.HostConfig.NetworkMode}}' dllpickle-offline > "$evidence/network-mode.txt" | ||
| test "$(cat "$evidence/network-mode.txt")" = none | ||
| status=0 | ||
| docker start --attach dllpickle-offline 2>&1 | tee "$evidence/offline-tests.log" || status=$? | ||
| mkdir -p "$evidence/results" | ||
| docker cp dllpickle-offline:/src/artifacts/oss-scanner/. "$evidence/results" || status=1 | ||
| test "$status" -eq 0 | ||
| jq -e '.status == "passed" and (.profiles | length > 0)' "$evidence/results/summary.json" | ||
| { | ||
| echo '### OSS Scanner environment' | ||
| echo 'Rebuilt and tested in a container with network mode `none`, 2 CPUs and 8 GiB RAM.' | ||
| echo 'Unit, synthetic integration, package composition and TFM checks passed for:' | ||
| jq -r '.profiles[] | "- PowerShell \(.PowerShellVersion), .NET \(.DotNetVersion), \(.TargetFramework)"' "$evidence/results/summary.json" | ||
| echo 'Tenant authentication and Windows/macOS execution are outside this check.' | ||
| } >> "$GITHUB_STEP_SUMMARY" | ||
|
|
||
| - name: Upload build and offline evidence | ||
| if: always() | ||
| uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 | ||
| with: | ||
| name: oss-scanner-evidence | ||
| path: ${{ runner.temp }}/oss-scanner-evidence/ | ||
| if-no-files-found: error | ||
| retention-days: 30 | ||
|
|
||
| - name: Remove test container | ||
| if: always() | ||
| shell: bash | ||
| run: docker rm --force dllpickle-offline 2>/dev/null || true |
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,64 @@ | ||
| # Keep the SDK image aligned with global.json; setup.ps1 checks the exact version. | ||
| FROM mcr.microsoft.com/dotnet/sdk:10.0.302-noble@sha256:72dd743782f2ae7e5476fd64f6a460045e3998dc862218b80e6944cba79a01b0 | ||
|
|
||
| SHELL ["/bin/bash", "-o", "pipefail", "-c"] | ||
| ENV DOTNET_CLI_TELEMETRY_OPTOUT=1 \ | ||
| DOTNET_NOLOGO=1 \ | ||
| POWERSHELL_TELEMETRY_OPTOUT=1 \ | ||
| NUGET_PACKAGES=/opt/nuget/packages | ||
|
|
||
| RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ | ||
| ca-certificates=20260816ubuntu0.24.04.2 \ | ||
| curl=8.5.0-2ubuntu10.16 \ | ||
| git=1:2.43.0-1ubuntu7.4 \ | ||
| jq=1.7.1-3ubuntu0.24.04.2 \ | ||
| python3=3.12.3-0ubuntu2.1 \ | ||
| procps=2:4.0.4-4ubuntu3.3 \ | ||
| libunwind8=1.6.2-3build1.1 \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| WORKDIR /src | ||
| # Keep tool provisioning cached when only source, tests or documentation change. | ||
| COPY global.json ./ | ||
| COPY build/build-tool-versions.json build/powershell-test-matrix.json build/DLLPickle.Tooling.ps1 ./build/ | ||
| COPY tools/Install-DLLPickleTestPowerShell.ps1 ./tools/ | ||
| COPY .github/ci-scripts/Actions_Bootstrap.ps1 ./.github/ci-scripts/ | ||
| COPY .oss-scanner/setup.ps1 ./.oss-scanner/ | ||
|
|
||
| # Bootstrap one PowerShell from the same checksum-pinned matrix used by CI. | ||
| # setup.ps1 then uses the existing provisioner to validate/install every profile. | ||
| RUN set -eu; \ | ||
| read -r url checksum < <(jq -er '[.archiveAssets[] | select(.platform == "linux" and .architecture == "x64")] | sort_by(.powerShellVersion | split(".") | map(tonumber)) | last | [.downloadUrl, .sha256] | @tsv' build/powershell-test-matrix.json); \ | ||
| curl --fail --location --proto '=https' --proto-redir '=https' --retry 3 "$url" -o /tmp/powershell.tar.gz; \ | ||
| printf '%s /tmp/powershell.tar.gz\n' "$checksum" | sha256sum --check --strict; \ | ||
| mkdir -p /opt/powershell-bootstrap; \ | ||
| tar -xzf /tmp/powershell.tar.gz -C /opt/powershell-bootstrap; \ | ||
| chmod +x /opt/powershell-bootstrap/pwsh; \ | ||
| /opt/powershell-bootstrap/pwsh -NoLogo -NoProfile -NonInteractive -File .oss-scanner/setup.ps1; \ | ||
| ln -s "$(jq -er 'sort_by(.PowerShellVersion | split(".") | map(tonumber)) | last | .ExecutablePath' /opt/dllpickle/runtimes.json)" /usr/local/bin/pwsh; \ | ||
| rm -rf /opt/powershell-bootstrap /tmp/powershell.tar.gz | ||
|
|
||
| # The scanner uses the repository as its build context and expects source at /src. | ||
| COPY . /src | ||
| # Restore every TFM's packages/reference packs and warm temporary test projects. | ||
| # The complete runtime matrix is exercised by the offline acceptance run. | ||
| RUN pwsh -NoLogo -NoProfile -NonInteractive -Command \ | ||
| '$env:PSModulePath = "/opt/dllpickle/modules" + [IO.Path]::PathSeparator + (Join-Path $PSHOME "Modules"); & ./tools/Invoke-DLLPickleBuild.ps1 -Task BuildCrossPlatform' | ||
|
|
||
| # Subsequent restores (including test fixtures) use only the retained package cache. | ||
| # This is image-local; normal repository builds still use their configured feeds. | ||
| RUN useradd --create-home --uid 10001 scanner \ | ||
| && mkdir -p /root/.config /home/scanner/.config \ | ||
| /root/.nuget/NuGet /home/scanner/.nuget/NuGet \ | ||
| && cp .oss-scanner/NuGet.Config /root/.nuget/NuGet/NuGet.Config \ | ||
| && cp .oss-scanner/NuGet.Config /home/scanner/.nuget/NuGet/NuGet.Config \ | ||
| && git config --file /root/.gitconfig --add safe.directory /src \ | ||
| && chown -R scanner:scanner /src /opt/nuget /home/scanner \ | ||
| && chmod -R a+rX /opt/dllpickle | ||
|
|
||
| ENV HOME=/home/scanner \ | ||
| PSModulePath=/opt/dllpickle/modules | ||
| # Anthropic's tooling layer switches to root; its offline NuGet config is ready too. | ||
| USER scanner | ||
| ENTRYPOINT [] | ||
| CMD ["bash"] | ||
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,13 @@ | ||
| .git | ||
| .claude | ||
| .vscode | ||
| .env | ||
| .env.* | ||
| artifacts | ||
| archive | ||
| module | ||
| **/bin | ||
| **/obj | ||
| .nuget | ||
| packages | ||
| *.nupkg |
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,10 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <configuration> | ||
| <packageSources> | ||
| <clear /> | ||
| <add key="image-cache" value="/opt/nuget/packages" /> | ||
| </packageSources> | ||
| <auditSources> | ||
| <clear /> | ||
| </auditSources> | ||
| </configuration> |
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,99 @@ | ||
| --- | ||
| title: OSS Scanner environment | ||
| summary: Prepare DLL Pickle for offline security analysis. | ||
| --- | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
|
|
||
| ## Build and verify | ||
|
|
||
| From the repository root on a Linux x64 Docker host: | ||
|
|
||
| ```sh | ||
| docker build -f .oss-scanner/Dockerfile -t dllpickle-oss-scanner . | ||
| docker run --rm --network none --cpus 2 --memory 8g \ | ||
| dllpickle-oss-scanner pwsh -NoLogo -NoProfile -NonInteractive \ | ||
| -File .oss-scanner/test.ps1 | ||
| ``` | ||
|
|
||
| The build downloads framework dependencies and warms test-project restores. | ||
| The second command rebuilds and tests in a new container with no networking | ||
| and no host files mounted. A successful image build alone is not offline | ||
| test evidence. | ||
|
|
||
| The image uses `global.json`, `build/build-tool-versions.json`, and | ||
| `build/powershell-test-matrix.json`. Update the SDK image tag and digest | ||
| when `global.json` changes; setup rejects a mismatch. Runtime archives use the | ||
| matrix checksums and the existing stock-PowerShell provisioner. Each runtime has | ||
| its own fresh processes and explicit module path. | ||
|
|
||
| The Dockerfile also pins its direct OS package versions. Review those pins with | ||
| base-image updates; expired package versions fail the build rather than silently | ||
| selecting replacements. Dependency feeds and transitive OS packages remain | ||
| external inputs, so these pins are not a claim of bit-for-bit reproducibility. | ||
|
|
||
| Source is at `/src`; the built module is at `/src/module/DLLPickle`. Tools and | ||
| runtimes live under `/opt/dllpickle`; the NuGet cache is `/opt/nuget/packages`. | ||
| The final image's user-level NuGet configuration permits only that local cache. | ||
| This does not change normal builds outside the image. Online dependency audits | ||
| remain in the existing dependency workflows; offline restores cannot refresh | ||
| vulnerability data. | ||
|
|
||
| The project image defaults to the unprivileged `scanner` user. Anthropic's | ||
| tooling layer switches to root; both users have the same offline NuGet policy. | ||
| The analysis source and NuGet cache are writable, while installed runtimes and | ||
| build tools remain root-owned. Root trusts only `/src` as a Git worktree owned | ||
| by another user, so the scanner can inspect patches after restoring `.git`. | ||
| Shared tools are on the default module path. | ||
|
|
||
| `test.ps1` runs the existing cross-platform build, then unit tests, synthetic | ||
| integration tests, strict package composition and TFM checks for every declared | ||
| Linux profile. Live service probes are disabled. JSON/XML results are separated | ||
| by runtime under `/src/artifacts/oss-scanner`; a passing summary is written only | ||
| after every check succeeds. | ||
|
|
||
| For interactive investigation: | ||
|
|
||
| ```sh | ||
| docker run --rm -it --network none dllpickle-oss-scanner bash | ||
| ``` | ||
|
|
||
| The reusable `OSS-Scanner.yml` workflow saves the source commit, image metadata, | ||
| network mode, build/test logs and per-runtime results for 30 days. | ||
| `Build Module` calls it for build-relevant changes and includes its result in | ||
| the existing Build gate. Documentation-only changes can skip expensive jobs. | ||
| Dependabot tracks the scanner image separately from the development container. | ||
|
|
||
| ## Enrollment after merge | ||
|
|
||
| Track preparation in | ||
| [issue #318](https://github.com/SamErde/DLLPickle/issues/318). | ||
| After the implementation PR is merged, create an upstream tracking issue and a | ||
| dedicated fork branch in `anthropics/oss-scanner`. Add only | ||
| `projects/dllpickle/project.yaml`, pointing to this Dockerfile and threat model. | ||
| Confirm the monitored primary security inbox before publishing the registration. | ||
|
|
||
| Run the upstream checks from the oss-scanner checkout: | ||
|
|
||
| ```sh | ||
| python3 tools/validate.py | ||
| python3 tools/check dllpickle | ||
| # Inside the resulting offline shell: | ||
| pwsh -NoLogo -NoProfile -NonInteractive -File .oss-scanner/test.ps1 | ||
| ``` | ||
|
|
||
| The helper clones the configured remote ref; it does not test unpublished local | ||
| files. Record the actual source revision and results in the enrollment PR. | ||
| Anthropic's build-only CI does not replace the offline test run. Its scanner | ||
| adds a tooling layer, so the project image's digest pin does not pin that layer. | ||
|
|
||
| Use the current upstream PR template and provide a factual security-criticality | ||
| and adoption rationale. The maintainer must make the contact, service terms and | ||
| CLA decisions. Creating these files does not enroll DLL Pickle or accept terms. | ||
| See [upstream contribution requirements](https://github.com/anthropics/oss-scanner/blob/main/CONTRIBUTING.md). | ||
|
|
||
| ## Coverage | ||
|
|
||
| This environment verifies Linux execution and synthetic authentication-module | ||
| interactions. It does not validate live tenant sign-in, Windows broker/WAM, | ||
| macOS execution, or the full upstream service-module compatibility matrix. | ||
| Existing release and compatibility checks remain necessary. See | ||
| [the threat model](threat_model.md) for analysis scope and severity guidance. | ||
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,43 @@ | ||
| <# | ||
| .SYNOPSIS | ||
| Installs the repository-pinned tools and Linux runtimes in the scanner image. | ||
| .DESCRIPTION | ||
| Runs during the network-enabled Docker build. Runtime archives are verified by | ||
| the existing provisioner; no tenant credentials or service modules are required. | ||
| #> | ||
| [CmdletBinding()] | ||
| param() | ||
|
|
||
| $ErrorActionPreference = 'Stop' | ||
| Set-StrictMode -Version Latest | ||
| $RepositoryRoot = Split-Path -Parent $PSScriptRoot | ||
| Set-Location -LiteralPath $RepositoryRoot | ||
|
|
||
| $SdkPolicy = Get-Content -LiteralPath 'global.json' -Raw | ConvertFrom-Json | ||
| $InstalledSdk = & dotnet --version | ||
| if ($LASTEXITCODE -ne 0 -or $InstalledSdk -ne $SdkPolicy.sdk.version) { | ||
| throw 'The scanner SDK image must match global.json exactly. Update its tag and digest together.' | ||
| } | ||
|
|
||
| $Matrix = Get-Content -LiteralPath 'build/powershell-test-matrix.json' -Raw | ConvertFrom-Json | ||
| if (@($Matrix.profiles).Count -eq 0) { | ||
| throw 'The PowerShell runtime matrix is empty.' | ||
| } | ||
| $RuntimeIdentities = @( | ||
| foreach ($RuntimeProfile in $Matrix.profiles) { | ||
| $InstallParameters = @{ | ||
| Provider = 'DirectArchive' | ||
| PowerShellVersion = $RuntimeProfile.powerShellVersion | ||
| InstallRoot = '/opt/dllpickle/runtimes' | ||
| Platform = 'linux' | ||
| Architecture = 'x64' | ||
| PassThru = $true | ||
| } | ||
| & ./tools/Install-DLLPickleTestPowerShell.ps1 @InstallParameters | ||
| } | ||
| ) | ||
| $RuntimeIdentities | ConvertTo-Json -Depth 10 -AsArray | | ||
| Set-Content -LiteralPath '/opt/dllpickle/runtimes.json' -Encoding utf8NoBOM | ||
|
|
||
| # Save-Module avoids a tool dependency on the invoking user's home directory. | ||
| & ./.github/ci-scripts/Actions_Bootstrap.ps1 -ModuleInstallPath '/opt/dllpickle/modules' |
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.
Uh oh!
There was an error while loading. Please reload this page.