diff --git a/.gitignore b/.gitignore index e100579..17c6d10 100644 --- a/.gitignore +++ b/.gitignore @@ -16,5 +16,6 @@ Thumbs.db # Local caches and temporary files .releasecheck-cache/ tmp/ +.tmp/ .gocache/ .gotmp/ diff --git a/CHANGELOG.md b/CHANGELOG.md index bb57806..e194217 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,8 @@ All notable changes to ReleaseCheck will be documented here. - Documented Sigstore, SLSA, and GitHub artifact-attestation interoperability boundaries. - Added v0.1.2 package-manager metadata and a pinned real npm/PyPI corpus record. +- Added an opt-in bounded corpus verifier that checks pinned artifact URLs, sizes, and SHA-256 digests without installing or executing packages. +- Normalized the full Apache-2.0 license text across the organization repositories. - Fixed inspection of GNU tar archives containing PAX global metadata headers. - Added stable report reason, explanation, missing/conflicting-evidence, and recommended-action fields with renderer tests. - Added a read-only non-publishing release rehearsal script/workflow and expanded contributor-ready issue specifications. diff --git a/LICENSE b/LICENSE index a52fafc..e1f9336 100644 --- a/LICENSE +++ b/LICENSE @@ -131,6 +131,9 @@ any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, @@ -171,3 +174,28 @@ of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include the + brackets!) The text should be enclosed in the appropriate comment + syntax for the file format. We also recommend that a file or class + name and description of purpose be included on the same "printed page" + as the copyright notice for easier identification within third-party + archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/PROJECT_CONTEXT.md b/PROJECT_CONTEXT.md index 7d2d058..4bc3f68 100644 --- a/PROJECT_CONTEXT.md +++ b/PROJECT_CONTEXT.md @@ -37,7 +37,7 @@ Out of scope: crates.io, Go modules, generic vulnerability scanning, SBOM genera ## Current implementation -The repository currently contains a Go CLI with npm and PyPI verification paths; bounded HTTPS acquisition; SHA-256 and supported npm integrity handling; safe ZIP/TAR.GZ inventory; source and artifact file comparison; deterministic structural security observations; provenance structure parsing and artifact binding; human, JSON, and SARIF reports with stable reason and next-action fields; stable exit codes; offline fixtures; contributor documentation; CI and release workflows; independent audit reports; pinned Go/Homebrew/Scoop installation metadata; and a metadata-only real npm/PyPI compatibility corpus. Public v0.1.2 release and Action E2E validation are complete. The product remains deliberately narrower than provenance infrastructure, reproducibility builders, vulnerability scanners, and repository-health tools. +The repository currently contains a Go CLI with npm and PyPI verification paths; bounded HTTPS acquisition; SHA-256 and supported npm integrity handling; safe ZIP/TAR.GZ inventory; source and artifact file comparison; deterministic structural security observations; provenance structure parsing and artifact binding; human, JSON, and SARIF reports with stable reason and next-action fields; stable exit codes; offline fixtures; contributor documentation; CI and release workflows; independent audit reports; pinned Go/Homebrew/Scoop installation metadata; and a metadata-only real npm/PyPI compatibility corpus with an opt-in bounded verifier. Public v0.1.2 release and Action E2E validation are complete. The product remains deliberately narrower than provenance infrastructure, reproducibility builders, vulnerability scanners, and repository-health tools. The current CLI is: @@ -87,7 +87,7 @@ The dependency relationship is one-way: the core releases versioned binaries; th - Phase 11 CLI: `releasecheck verify npm [flags] NAME [VERSION]` and `releasecheck verify pypi [flags] NAME [VERSION]` wire the existing adapters to human, JSON, and SARIF output. `--artifact` selects a PyPI file, `--timeout` bounds operations, `--output` writes a report with restrictive permissions, and exit codes follow the report contract. No public SDK is exposed yet because the internal adapter/result lifecycle is not stable enough to promise compatibility. - Phase 12 release engineering: CI tests Ubuntu, Windows, and macOS with read-only permissions, runs an Ubuntu race job, pins third-party actions to immutable release commit SHAs, and builds the CLI for five target pairs from version tags. Release archives use `-trimpath`, `-buildvcs=false`, disabled CGO, normalized archive metadata, and SHA-256 checksums. Reproducibility is explicitly described as measured enough for v0.1 preparation, not a bit-for-bit guarantee. - Phase 13 documentation: README, usage, report-contract, CI, registry-adapter, and scoped good-first-issue guidance now describe the implemented CLI and its boundaries. Contributor and feature-request templates require deterministic tests, security impact, evidence, scope, and limitations. Documentation intentionally makes no adoption, novelty, safety, or hosted-CI claims. -- License: Apache-2.0 for a permissive license with an explicit patent grant and familiar enterprise/open-source reuse terms; MIT remains a possible future reconsideration only through a documented project decision. +- License: Apache-2.0 for a permissive license with an explicit patent grant and familiar enterprise/open-source reuse terms; all three repositories now carry the canonical full text. GitHub classifier re-indexing remains an external verification step; `NOASSERTION` must not be described as fixed until the API reports Apache-2.0. - Untrusted bytes are downloaded over HTTPS with timeouts and bounded storage. Archive paths, links, expansion, file counts, and sizes are validated. Symlinks and special entries are observed safely and are never followed during comparison. Package code, install hooks, setup.py, build backends, and lifecycle scripts are never executed. ## Research conclusions diff --git a/README.md b/README.md index 966fc85..e5a0d80 100644 --- a/README.md +++ b/README.md @@ -89,6 +89,12 @@ Go's module installer is also supported for a pinned release: go install github.com/ReleaseCheck/releasecheck/cmd/releasecheck@v0.1.2 ``` +The pinned real-release corpus can be downloaded and verified without installation or execution: + +```text +go run ./cmd/corpuscheck -output-dir .tmp/corpus +``` + The Homebrew formula and Scoop manifest are release metadata prepared for future tap/bucket publication; they are not official package indexes yet. The Phase 12 release workflow publishes archives for Linux amd64/arm64, macOS amd64/arm64, and Windows amd64 when a version tag is created. See [docs/RELEASE.md](docs/RELEASE.md). diff --git a/ROADMAP.md b/ROADMAP.md index a5dc59f..e88d123 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -70,8 +70,10 @@ This is the single status overview for the whole roadmap. The detailed sections | --- | --- | --- | --- | | Release-state and license truth pass | COMPLETE | Current v0.1.2 state in `PROJECT_CONTEXT.md`, `README.md`, `AUDIT_REPORT.md`, `FINAL_AUDIT.md`, Action README, and docs README; Apache-2.0 remains the canonical license in all three repositories | Historical audit checkpoints remain labeled as history; no false release or license claim is retained | | Sigstore/SLSA/GitHub attestation interoperability | COMPLETE | `docs/ATTESTATIONS.md`, `docs/DESIGN.md`, and docs repository `docs/attestations.md` | v0.1.2 consumes/reports evidence boundaries; it does not implement trust-root verification or publish GitHub attestations | -| Package-manager installation metadata | COMPLETE | `packaging/homebrew/releasecheck.rb`, `packaging/scoop/releasecheck.json`, pinned `go install` instructions | Official Homebrew tap and Scoop bucket publication are not claimed | -| Real npm/PyPI compatibility corpus | COMPLETE | `fixtures/corpus/real-releases.json`, corpus README, offline schema test | Metadata and digests are pinned; package bytes are not committed or executed, and live registry checks remain opt-in | +| Package-manager installation metadata | PARTIAL | Pinned `go install` is usable; Homebrew/Scoop manifests are prepared metadata only | Official Homebrew tap and Scoop bucket publication remain owner/repository work | +| Real npm/PyPI compatibility corpus | COMPLETE | `fixtures/corpus/real-releases.json`, `cmd/corpuscheck`, corpus README, offline schema test; live verification confirmed three artifacts on 2026-10-20 | Package bytes are downloaded only to an ignored output directory and are never installed or executed | +| Cross-platform GitHub Action acquisition | IN PROGRESS | Platform dispatch and Windows PowerShell verifier added in `releasecheck-action` review branch | Hosted matrix must pass before completion; Action remains limited to published release targets | +| GitHub license classifier | IN PROGRESS | Canonical Apache-2.0 text normalized in all three repositories | GitHub must re-index the files; `NOASSERTION` is not considered fixed until the API reports Apache-2.0 | ## Current Repository Architecture diff --git a/cmd/corpuscheck/main.go b/cmd/corpuscheck/main.go new file mode 100644 index 0000000..3e0619b --- /dev/null +++ b/cmd/corpuscheck/main.go @@ -0,0 +1,162 @@ +// Command corpuscheck downloads and verifies the pinned corpus metadata. +// It never installs, imports, extracts, or executes the downloaded artifacts. +package main + +import ( + "crypto/sha256" + "encoding/hex" + "encoding/json" + "errors" + "flag" + "fmt" + "io" + "net/http" + "net/url" + "os" + "path/filepath" + "strings" + "time" +) + +const maxArtifactBytes int64 = 100 << 20 + +type corpus struct { + Records []record `json:"records"` +} +type record struct { + Ecosystem string `json:"ecosystem"` + Package string `json:"package"` + ArtifactURL string `json:"artifact_url"` + ArtifactName string `json:"artifact_filename"` + ArtifactSize int64 `json:"artifact_size"` + ArtifactSHA256 string `json:"artifact_sha256"` + Artifacts []artifact `json:"artifacts"` +} +type artifact struct { + ArtifactURL string `json:"artifact_url"` + ArtifactName string `json:"artifact_filename"` + ArtifactSize int64 `json:"artifact_size"` + ArtifactSHA256 string `json:"artifact_sha256"` +} + +func main() { + corpusPath := flag.String("corpus", "fixtures/corpus/real-releases.json", "corpus metadata JSON path") + outputDir := flag.String("output-dir", "", "directory for verified artifact bytes; empty uses a temporary directory") + timeout := flag.Duration("timeout", 30*time.Second, "per-request timeout") + flag.Parse() + if *timeout <= 0 { + fail(errors.New("timeout must be positive")) + } + data, err := os.ReadFile(*corpusPath) + if err != nil { + fail(fmt.Errorf("read corpus: %w", err)) + } + var entries corpus + if err := json.Unmarshal(data, &entries); err != nil { + fail(fmt.Errorf("parse corpus: %w", err)) + } + + directory := *outputDir + removeDirectory := false + if directory == "" { + directory, err = os.MkdirTemp("", "releasecheck-corpus-") + if err != nil { + fail(fmt.Errorf("create temporary output directory: %w", err)) + } + removeDirectory = true + } + if err := os.MkdirAll(directory, 0700); err != nil { + fail(fmt.Errorf("create output directory: %w", err)) + } + if removeDirectory { + defer os.RemoveAll(directory) + } + + client := &http.Client{Timeout: *timeout, CheckRedirect: func(req *http.Request, via []*http.Request) error { + if req.URL.Scheme != "https" || req.URL.User != nil { + return errors.New("redirect must remain HTTPS and cannot include userinfo") + } + if len(via) >= 5 { + return errors.New("redirect limit exceeded") + } + return nil + }} + count := 0 + for _, entry := range entries.Records { + items := []artifact{{ArtifactURL: entry.ArtifactURL, ArtifactName: entry.ArtifactName, ArtifactSize: entry.ArtifactSize, ArtifactSHA256: entry.ArtifactSHA256}} + if entry.ArtifactURL == "" { + items = entry.Artifacts + } + for _, item := range items { + if item.ArtifactURL == "" { + continue + } + if err := verifyArtifact(client, directory, entry, item); err != nil { + fail(err) + } + count++ + fmt.Printf("verified %s %s %s\n", entry.Ecosystem, entry.Package, item.ArtifactName) + } + } + fmt.Printf("verified %d artifact(s); no package code was executed\n", count) +} + +func verifyArtifact(client *http.Client, directory string, entry record, item artifact) error { + u, err := url.Parse(item.ArtifactURL) + if err != nil || u.Scheme != "https" || u.Host == "" || u.User != nil { + return fmt.Errorf("%s %s: artifact URL must be HTTPS without userinfo", entry.Package, item.ArtifactURL) + } + name := filepath.Base(item.ArtifactName) + if name == "." || name == string(filepath.Separator) || name != item.ArtifactName || strings.ContainsAny(item.ArtifactName, `/\\`) { + return fmt.Errorf("%s %s: artifact filename must be a plain filename", entry.Package, item.ArtifactName) + } + if len(item.ArtifactSHA256) != sha256.Size*2 { + return fmt.Errorf("%s %s: invalid SHA-256 length", entry.Package, item.ArtifactName) + } + if _, err := hex.DecodeString(item.ArtifactSHA256); err != nil { + return fmt.Errorf("%s %s: invalid SHA-256 digest: %w", entry.Package, item.ArtifactName, err) + } + + response, err := client.Get(item.ArtifactURL) + if err != nil { + return fmt.Errorf("download %s: %w", item.ArtifactURL, err) + } + defer response.Body.Close() + if response.StatusCode < http.StatusOK || response.StatusCode >= http.StatusMultipleChoices { + return fmt.Errorf("download %s: HTTP %s", item.ArtifactURL, response.Status) + } + if response.ContentLength > maxArtifactBytes { + return fmt.Errorf("download %s: content length exceeds %d bytes", item.ArtifactURL, maxArtifactBytes) + } + + temporary, err := os.CreateTemp(directory, ".download-*") + if err != nil { + return fmt.Errorf("create temporary artifact: %w", err) + } + temporaryName := temporary.Name() + defer os.Remove(temporaryName) + hash := sha256.New() + bytes, err := io.Copy(io.MultiWriter(temporary, hash), io.LimitReader(response.Body, maxArtifactBytes+1)) + closeErr := temporary.Close() + if err != nil { + return fmt.Errorf("write %s: %w", item.ArtifactName, err) + } + if closeErr != nil { + return fmt.Errorf("close %s: %w", item.ArtifactName, closeErr) + } + if bytes > maxArtifactBytes { + return fmt.Errorf("download %s: exceeds %d bytes", item.ArtifactURL, maxArtifactBytes) + } + if item.ArtifactSize > 0 && bytes != item.ArtifactSize { + return fmt.Errorf("%s: size mismatch: got %d, expected %d", item.ArtifactName, bytes, item.ArtifactSize) + } + if !strings.EqualFold(hex.EncodeToString(hash.Sum(nil)), item.ArtifactSHA256) { + return fmt.Errorf("%s: SHA-256 mismatch", item.ArtifactName) + } + if err := os.Rename(temporaryName, filepath.Join(directory, name)); err != nil { + return fmt.Errorf("store verified %s: %w", item.ArtifactName, err) + } + return nil +} + +func fail(err error) { fmt.Fprintln(os.Stderr, err); os.Exit(1) } diff --git a/fixtures/corpus/README.md b/fixtures/corpus/README.md index 4ec2fbc..c4fb4b1 100644 --- a/fixtures/corpus/README.md +++ b/fixtures/corpus/README.md @@ -4,6 +4,14 @@ This directory records pinned public npm/PyPI examples for reproducible compatib The records are supplemental to the offline test suite. They are not fetched during default CI because public registries, source hosts, and release metadata can change or become unavailable. A live corpus check must be explicit, network-enabled, bounded, and non-executing. +Run the opt-in verifier from the repository root: + +```text +go run ./cmd/corpuscheck -output-dir .tmp/corpus +``` + +It downloads only the pinned URLs, checks HTTPS, redirect limits, size bounds, expected sizes, and SHA-256 digests, then stores the verified bytes in the requested directory. It never installs, extracts, imports, or executes an artifact. `.tmp/` is ignored by Git and should be deleted when no longer needed. + Each record includes: - registry, package, and version;