Skip to content

feat(attest): add --no-commit-info to attest without CI commit and repo info - #1420

Open
mbevc1 wants to merge 3 commits into
mainfrom
20261127_attest-no-commit-info
Open

mbevc1 wants to merge 3 commits into
mainfrom
20261127_attest-no-commit-info

Conversation

@mbevc1

@mbevc1 mbevc1 commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Adds --no-commit-info to the kosli attest commands, so an attestation can be sent without the commit and repository info the CLI defaults from the CI environment.

In a supported CI, the attest commands default --commit and the repository flags from the environment. A job in one repository that attests to a trail belonging to another repository's build therefore attaches its own commit and repository to that trail. There was no supported way to prevent this: --commit="" is refused as an empty value, and leaving the flag out restores the default.

Closes #1418

kosli attest generic --flow F --trail T --name security-scan --compliant=true --no-commit-info
  • Commit: no git_commit_info is sent, with no commit lookup and no warning, with or without a checkout.
  • Repository: the repo info defaulted from the CI environment is left out. --repository, --repo-url, --repo-id and --repo-provider are sent only when passed explicitly, so the caller can name the repository the trail belongs to.
  • No mixing: explicit repo flags are not completed from the CI's values. A partial set sends no repo info, with the existing warning that ID, name and URL are all required.
  • Origin URL: still sent. It records which workflow run sent the attestation, which stays true.
  • With --commit: fails, whether the commit was passed as a flag or set through KOSLI_COMMIT or the config file.
  • Pull request and Jira attestations: fail, since they need the commit to find pull requests or Jira issue keys.

Options considered

The issue lists three. This PR implements the first.

  • A general --no-ci-defaults switch: rejected as too broad. It would also drop the origin URL, and each command would need its own definition of "no defaults".
  • Allowing --commit="": rejected. An exception to the empty-value rule would let an unset shell variable drop the commit silently.

Notes for review

  • Scope: the flag is on the 13 commands that share the common attestation flags. kosli attest artifact, kosli attest in-toto and kosli begin trail are unchanged; the issue covers attesting to an existing trail.
  • Repo flags from the environment: KOSLI_REPOSITORY and the other repo variables count as explicit, like the flags, and are sent.
  • attest sonar: --sonar-revision still defaults to the CI commit, since it names the revision that was scanned, not a commit attached to the attestation.
  • Artifact binding: Kosli binds an attestation reported before its artifact through the commit. With this flag, an artifact attestation needs the artifact to exist already or --fingerprint to be passed.
  • Empty-flag audit: the flag is registered for the 13 commands (empty-flag-audit-coverage.json, spec.json, categories.json). The five commands that need the commit use the value false in the spec, since true fails there by design.

Checklist

  • Docs are autogenerated from CLI help — make sure the help text reflects your changes
  • Helm chart (charts/k8s-reporter/) updated, if needed. Note: these changes live in a separate PR (not needed)
  • Terraform provider and related changes (terraform-provider-kosli, terraform-aws-kosli-reporter) updated, if needed (not needed)

@github-actions github-actions Bot added go Pull requests that update go code feat labels Nov 27, 2026
@claude

claude Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @mbevc1's task in 1m 44s —— View job


Follow-up review — commits since last review

  • Fetch previous review comments
  • Diff BEFORE..AFTER (BEFORE 427ae3a1 isn't reachable locally — the branch was rebased onto current main, so SHAs changed but content didn't; confirmed by diffing the last two in-branch commits and the full origin/main...HEAD diff, which matches the PR's reported +202/-13 across the same 8 files)
  • Check status of each previous finding
  • Scan changed lines for new bugs/regressions
  • Post summary

Previous finding status:

  1. cmd/kosli/attestation.go — error message wrongly attributed --commit to KOSLI_COMMIT/config when it was passed as a flag (finding): RESOLVED. The message is now source-agnostic — "--no-commit-info cannot be combined with --commit, whether passed as a flag or set through KOSLI_COMMIT or the config file" — in both attestation.go and the two assertions in attestationCommitInfo_test.go that previously expected the old wording. This was already confirmed resolved in a prior reply on that thread; no further action needed there.

No new inline comments — the only change since the last review is this wording fix, and it introduces no new issues.

Comment thread cmd/kosli/attestation.go Resolved
@mbevc1
mbevc1 marked this pull request as ready for review November 27, 2026 22:13
…po info

In a supported CI the attest commands default --commit and the repository
flags from the environment. A job in one repository that attests to a
trail belonging to another repository's build therefore attached its own
commit and repository to that trail, and had no supported way not to:
--commit="" is refused as an empty value, and leaving the flag out
restores the default.

--no-commit-info sends the attestation without git_commit_info and
without the repository info defaulted from the CI environment, with no
commit lookup and no warning. Repository flags passed explicitly are
still sent, so the caller can name the repository the trail belongs to;
they are not completed from the CI's values. The origin URL is kept: it
says where the attestation was sent from, which stays true.

The flag fails with an explicit --commit, and on the pull request and
Jira attestations, which need the commit to do their work.

A general switch for all CI defaults was rejected as too broad, and
allowing --commit="" as an exception to the empty-value rule would let
an unset shell variable drop the commit silently.

Closes #1418
…flict

The golden page for attest snyk lists every flag of the command, so the
new --no-commit-info flag made TestDocsCmdSnyk fail.

A commit set through KOSLI_COMMIT or the config file counts as passed,
so a pipeline exporting it met an error naming a flag nobody typed. The
message now says where else the value can come from.

Refs #1418
…-commit

The message blamed KOSLI_COMMIT or the config file even when --commit
was typed on the command line, which is the common case.

Refs #1418
@mbevc1
mbevc1 force-pushed the 20261127_attest-no-commit-info branch from 427ae3a to 71cb17f Compare November 27, 2026 22:13
@mbevc1
mbevc1 enabled auto-merge (squash) November 27, 2026 22:17
@mbevc1
mbevc1 disabled auto-merge November 28, 2026 20:43
@mbevc1

mbevc1 commented Nov 28, 2026

Copy link
Copy Markdown
Contributor Author

#1421 needs to be reviewed and merged first!

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat go Pull requests that update go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No way to opt out of CI-defaulted --commit on kosli attest when attesting cross-repo

1 participant