|
| 1 | +name: bughunt nuget probe |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: ['bughunt/nuget/**'] |
| 5 | +permissions: |
| 6 | + contents: read |
| 7 | +jobs: |
| 8 | + probe: |
| 9 | + runs-on: ${{ matrix.os }} |
| 10 | + timeout-minutes: 45 |
| 11 | + strategy: |
| 12 | + fail-fast: false |
| 13 | + matrix: |
| 14 | + include: |
| 15 | + - {os: windows-latest} |
| 16 | + - {os: windows-2022} |
| 17 | + steps: |
| 18 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 19 | + with: |
| 20 | + persist-credentials: false |
| 21 | + - run: rustup show |
| 22 | + - run: cargo build --release -p socket-patch-cli |
| 23 | + - name: probe |
| 24 | + shell: bash |
| 25 | + env: |
| 26 | + SOCKET_OFFLINE: '1' |
| 27 | + run: | |
| 28 | + set +e +o pipefail |
| 29 | + unset NUGET_PACKAGES |
| 30 | + SP="$GITHUB_WORKSPACE/target/release/socket-patch" |
| 31 | + W="$RUNNER_TEMP/bh"; rm -rf "$W"; mkdir -p "$W"; cd "$W" |
| 32 | + curl -sSL -o nuget.exe https://dist.nuget.org/win-x86-commandline/latest/nuget.exe; ./nuget.exe help | head -1 |
| 33 | + DEF="$(cygpath -u "$USERPROFILE")/.nuget/packages" |
| 34 | + blob(){ local l; l=$(wc -c < "$1" | tr -d ' '); { printf 'blob %s\0' "$l"; cat "$1"; } | sha256sum | cut -d' ' -f1; } |
| 35 | + stage(){ local o="$1" p="$2" bh ah; bh=$(blob "$o"); ah=$(blob "$p") |
| 36 | + mkdir -p .socket/blobs; cp "$p" ".socket/blobs/$ah"; cp "$o" ".socket/blobs/$bh" |
| 37 | + printf '{"patches":{"pkg:nuget/Newtonsoft.Json@13.0.3":{"uuid":"11111111-1111-4111-8111-111111111111","exportedAt":"2026-01-01T00:00:00Z","files":{"LICENSE.md":{"beforeHash":"%s","afterHash":"%s"}},"vulnerabilities":{},"description":"m","license":"MIT","tier":"free"}}}' "$bh" "$ah" > .socket/manifest.json; } |
| 38 | + res(){ echo "RESULT[$ImageOS] $*"; } |
| 39 | + mk(){ # $1 dir, $2 repositoryPath or empty |
| 40 | + mkdir -p "$1/App"; cd "$1" |
| 41 | + printf '<?xml version="1.0" encoding="utf-8"?>\n<packages>\n <package id="Newtonsoft.Json" version="13.0.3" targetFramework="net472" />\n</packages>\n' > App/packages.config |
| 42 | + printf '<?xml version="1.0" encoding="utf-8"?>\n<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\n <PropertyGroup><ProjectGuid>{11111111-2222-3333-4444-555555555555}</ProjectGuid><OutputType>Library</OutputType><TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion></PropertyGroup>\n <ItemGroup><None Include="packages.config" /></ItemGroup>\n</Project>\n' > App/App.csproj |
| 43 | + printf 'Microsoft Visual Studio Solution File, Format Version 12.00\r\nProject("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "App", "App\\App.csproj", "{11111111-2222-3333-4444-555555555555}"\r\nEndProject\r\n' > App.sln |
| 44 | + if [ -n "$2" ]; then printf '<?xml version="1.0" encoding="utf-8"?>\n<configuration>\n <config><add key="repositoryPath" value="%s" /></config>\n</configuration>\n' "$2" > nuget.config; fi |
| 45 | + "$W/nuget.exe" restore App.sln -NonInteractive > r.log 2>&1 || cat r.log |
| 46 | + find . -name LICENSE.md -path '*ewtonsoft*' | head -3; } |
| 47 | + warm(){ rm -rf "$DEF/newtonsoft.json/13.0.3"; mkdir -p "$W/warm"; (cd "$W/warm"; printf '<Project Sdk="Microsoft.NET.Sdk"><PropertyGroup><TargetFramework>net8.0</TargetFramework></PropertyGroup><ItemGroup><PackageReference Include="Newtonsoft.Json" Version="13.0.3" /></ItemGroup></Project>' > w.csproj; dotnet restore --force > r.log 2>&1 || cat r.log); } |
| 48 | + for CASE in "default|" "repopath|lib/pkgs" "warmrepopath|lib/pkgs"; do |
| 49 | + N=${CASE%%|*}; RP=${CASE#*|} |
| 50 | + case $N in warm*) warm;; *) rm -rf "$DEF/newtonsoft.json/13.0.3";; esac |
| 51 | + mk "$W/$N" "$RP" |
| 52 | + L=$(find . -name LICENSE.md -path '*ewtonsoft.Json.13.0.3*' | head -1) |
| 53 | + [ -n "$L" ] || { res "[$N] nuget.exe restore did not produce package"; cd "$W"; continue; } |
| 54 | + cp "$L" "$W/pr.md"; cp "$W/pr.md" "$W/pa.md"; printf '\nSOCKET-MARKER\n' >> "$W/pa.md"; stage "$W/pr.md" "$W/pa.md" |
| 55 | + "$SP" apply --offline > a.log 2>&1; rc=$?; tail -3 a.log |
| 56 | + grep -q SOCKET-MARKER "$L" && pl=PATCHED || pl=UNPATCHED |
| 57 | + [ -f "$DEF/newtonsoft.json/13.0.3/LICENSE.md" ] && { grep -q SOCKET-MARKER "$DEF/newtonsoft.json/13.0.3/LICENSE.md" && dl=PATCHED || dl=untouched; } || dl=absent |
| 58 | + res "[$N] repositoryPath='$RP' copy=$L apply rc=$rc repo-copy=$pl default-cache=$dl" |
| 59 | + cd "$W" |
| 60 | + done |
| 61 | + echo "==== summary"; true |
0 commit comments