1
0
mirror of synced 2026-10-24 12:59:22 +03:00

11 Commits

Author SHA1 Message Date
Eugene Kalinin
e9af93ff29 fix(providers): clearer errors when GitHub OIDC token request fails (#5062)
The GitHub Actions provider decoded the response body without checking the
status code, so a failing OIDC endpoint surfaced as a raw json error:

  fetching ambient OIDC credentials: invalid character 'u' looking for
  beginning of value

Check the status code first and report it along with a truncated body, and
wrap decode failures with the provider name:

  fetching ambient OIDC credentials: identity token request to provider
  github-actions failed with status 502 Bad Gateway: "upstream connect
  error or disconnect/reset before headers"

Fixes #4438

Signed-off-by: Eugene Kalinin <e.v.kalinin@gmail.com>
2026-08-18 09:09:02 -07:00
Sebastien Tardif
8a86a7cf84 fix: use Header.Set to prevent duplicate Authorization on retry (#4870)
The GitHub Actions OIDC token provider uses Header.Add inside a retry
loop. On each retry iteration, an additional Authorization header is
appended to the request. By the third attempt, three identical headers
are sent. Some servers and proxies reject requests with duplicate
Authorization headers, causing retries to fail when they should
succeed.

Replace Header.Add with Header.Set so only one Authorization header
is ever present, regardless of how many retries occur.

Add a test that forces two retries via connection hijack and asserts
exactly one Authorization header is received on every attempt.

Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
2026-05-18 09:40:23 -04:00
Hayden
8e3a787545 Bump module version to v3 for Cosign v3.0 (#4427)
Signed-off-by: Hayden <8418760+haydentherapper@users.noreply.github.com>
Co-authored-by: Hayden <8418760+haydentherapper@users.noreply.github.com>
2025-09-26 13:31:26 -07:00
Ville Skyttä
c03e2a8f88 More linting coverage (#4213)
* Remove explicit staticcheck and unused linter enables

They are enabled by default. For consistency, do not list them like
others that are enabled by default (for example govet) are not
explicitly listed either.

Signed-off-by: Ville Skyttä <ville.skytta@iki.fi>

* Enable makezero and nilnesserr linters

There are no findings from either at the moment, but they serve useful
purposes.

Signed-off-by: Ville Skyttä <ville.skytta@iki.fi>

* Ensure closing of TSA response body, enable bodyclose linter

This was flagged by bodyclose.

Signed-off-by: Ville Skyttä <ville.skytta@iki.fi>

* Vet internal ui.Infof/Warnf uses

Signed-off-by: Ville Skyttä <ville.skytta@iki.fi>

* Enable usestdlibvars linter, address findings

Signed-off-by: Ville Skyttä <ville.skytta@iki.fi>

* test: update e2e rekor service count

https://github.com/sigstore/cosign/pull/4213#pullrequestreview-2876276830

Signed-off-by: Ville Skyttä <ville.skytta@iki.fi>

* Update e2e_test.sh to handle different healthy service totals

Rekor has healthchecks for 5 services, Fulcio currently has healthchecks for 3.

Signed-off-by: Hayden B <haydentherapper@users.noreply.github.com>

---------

Signed-off-by: Ville Skyttä <ville.skytta@iki.fi>
Signed-off-by: Hayden B <haydentherapper@users.noreply.github.com>
Co-authored-by: Hayden B <haydentherapper@users.noreply.github.com>
2025-05-30 10:26:07 -07:00
Jon Johnson
c049cef04a Handle HTTP_1_1_REQUIRED errors in github provider (#3172)
I've been seeing this quite a bit recently. I'm not sure why it happens,
but hopefully this helps.

Also, plumb context into the right place.

Signed-off-by: Jon Johnson <jon.johnson@chainguard.dev>
2023-08-09 12:04:13 +02:00
Jason Hall
b57ccbc835 retry GH OIDC requests up to 3 times (#2991)
Signed-off-by: Jason Hall <jason@chainguard.dev>
2023-05-18 12:13:14 -04:00
Carlos Tadeu Panato Junior
09004f2c5d update golangci-lint to v1.52.2 (#2851)
* update golangci-lint to v1.52.2

Signed-off-by: cpanato <ctadeu@gmail.com>

* fix lints

Signed-off-by: cpanato <ctadeu@gmail.com>

---------

Signed-off-by: cpanato <ctadeu@gmail.com>
2023-04-04 15:33:55 -07:00
priyawadhwa
27bb6ad4c6 Change go module name to github.com/sigstore/cosign/v2 for Cosign 2.0 (#2544)
* Change go module name to github.com/sigstore/cosgn/v2 for Cosign 2.0

Signed-off-by: Priya Wadhwa <priya@chainguard.dev>

* Update ko paths

Signed-off-by: Priya Wadhwa <priya@chainguard.dev>

Signed-off-by: Priya Wadhwa <priya@chainguard.dev>
2022-12-14 10:54:48 -05:00
Zack Newman
f101debf98 Replace accidentally-removed public constants (#2370)
These were removed in #2322, which made it an accidentally-semver-breaking
change. This unbreaks semver.

These should be removed at the next major version release or sooner if we decide
keeping semver is not important.

Signed-off-by: Zachary Newman <zjn@chainguard.dev>

Signed-off-by: Zachary Newman <zjn@chainguard.dev>
2022-10-21 19:42:50 -04:00
Marko Mudrinić
285459e2ac feat: Implement 'env' package to handle environment variables in cosign (#2322)
* Implement 'env' package to handle environment variables

Signed-off-by: Marko Mudrinić <mudrinic.mare@gmail.com>

* Make 'cosign env' use the env package

Signed-off-by: Marko Mudrinić <mudrinic.mare@gmail.com>

* Make packages use env instead os.Getenv/LookupEnv

Signed-off-by: Marko Mudrinić <mudrinic.mare@gmail.com>

* Fix oci unit test

Signed-off-by: Marko Mudrinić <mudrinic.mare@gmail.com>

* Fix E2E tests

Signed-off-by: Marko Mudrinić <mudrinic.mare@gmail.com>

* Address review comments

Signed-off-by: Marko Mudrinić <mudrinic.mare@gmail.com>

* Update docgen

Signed-off-by: Marko Mudrinić <mudrinic.mare@gmail.com>

* Integrate forbidigo linter for os.Getenv/LookupEnv

Signed-off-by: Marko Mudrinić <mudrinic.mare@gmail.com>

* Document all environment variables used by cosign

Signed-off-by: Marko Mudrinić <mudrinic.mare@gmail.com>

* Address review comments - part 2

Signed-off-by: Marko Mudrinić <mudrinic.mare@gmail.com>

* Fix issue with tests conflicting with OS envs

Signed-off-by: Marko Mudrinić <mudrinic.mare@gmail.com>

* Address review comments - part 3

Signed-off-by: Marko Mudrinić <mudrinic.mare@gmail.com>

* Fix gocritic lint errors

Signed-off-by: Marko Mudrinić <mudrinic.mare@gmail.com>

Signed-off-by: Marko Mudrinić <mudrinic.mare@gmail.com>
2022-10-17 21:37:35 +00:00
Matt Moore
739947de3d Add logic to detect and use ambient OIDC from exec envs. (#644)
This is based on some work I have been doing here: https://github.com/mattmoor/oidc-magic

At present, it is fairly tedious to use the "keyless" flow inside of environments that have a form of ambient OIDC (e.g. GKE workload identity).  For example, in the context of Tekton, one needs to overlay `cosign` on an image like `docker.io/google/cloud-sdk:slim`, and then during execution have the step do something like:

```yaml
command: ["/bin/sh"]
args:
- "-c"
- |
  # Generate an identity token.
  IDENTITY_TOKEN=$(gcloud auth print-identity-token --audiences=sigstore)

  # Use the identity token to sign the image.
  cosign sign \
    -identity-token $IDENTITY_TOKEN \
    my.registry/the-image@sha256:deadbeef
```

This change adds support for detecting when `cosign` is executing within an environment with this kind of ambient authentication, and automatically producing one when `-identity-token` is not specified (and `COSIGN_EXPERIMENTAL=true`).

This means the same signing can now be done with:

```yaml
args: ["sign", "my.registry/the-image@sha256:deadbeef"]
```

This is much simpler, but also the image will be both smaller (distroless) and more portable (not just GCP, but any provider we link).

Signed-off-by: Matt Moore <mattomata@gmail.com>
2021-09-10 21:21:00 -05:00