Skip to content

Commit fea376a

Browse files
Merge pull request #207 from intelops/add-checks-for-templates
Add checks for templates
2 parents 301a9f9 + 1d96b03 commit fea376a

File tree

6,887 files changed

+2019271
-12313
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

6,887 files changed

+2019271
-12313
lines changed

.github/workflows/ci.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,24 @@ jobs:
1717
actions: read
1818
steps:
1919
- name: Checkout repository
20-
uses: actions/checkout@v3
20+
uses: actions/checkout@v4
2121
with:
2222
submodules: recursive
2323
token: ${{ secrets.GH_TOKEN }}
2424
- name: Set up Go
25-
uses: actions/setup-go@v4
25+
uses: actions/setup-go@v5
2626
with:
27-
go-version: '1.20'
27+
go-version: '1.22'
2828
cache-dependency-path: '**/go.sum'
2929
- name: Build
3030
run: |
3131
go build -v ./...
3232
- name: golangci-lint
3333
run: |
34-
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.52.2
34+
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.57.2
3535
golangci-lint run
3636
- name: Install Protoc
37-
uses: arduino/setup-protoc@v2
37+
uses: arduino/setup-protoc@v3
3838
with:
3939
version: "23.x"
4040
- name: Test
@@ -51,7 +51,7 @@ jobs:
5151
go run main.go pullTemplates --all
5252
go test -v ./... -race -coverprofile=coverage.out -coverpkg=./... -covermode=atomic
5353
- name: Upload coverage to Codecov
54-
uses: codecov/codecov-action@v3
54+
uses: codecov/codecov-action@v4
5555
with:
5656
files: ./coverage.out
5757
flags: core
@@ -83,14 +83,14 @@ jobs:
8383
security-events: write
8484
steps:
8585
- name: Checkout GitHub Action
86-
uses: actions/checkout@v3
86+
uses: actions/checkout@v4
8787
# setup Docker build action
8888
- name: Set up Docker Buildx
8989
id: buildx
90-
uses: docker/setup-buildx-action@v2
90+
uses: docker/setup-buildx-action@v3
9191
- name: Docker metadata
9292
id: metadata
93-
uses: docker/metadata-action@v4
93+
uses: docker/metadata-action@v5
9494
with:
9595
images: ${{ env.REGISTRY }}/${{ github.repository }}
9696
tags: |
@@ -100,13 +100,13 @@ jobs:
100100
flavor: |
101101
latest=true
102102
- name: Login to GitHub Container Registry
103-
uses: docker/login-action@v2
103+
uses: docker/login-action@v3
104104
with:
105105
registry: ${{ env.REGISTRY }}
106106
username: ${{ github.actor }}
107107
password: ${{ secrets.GH_TOKEN }}
108108
- name: Build image and push to GitHub Container Registry
109-
uses: docker/build-push-action@v4
109+
uses: docker/build-push-action@v5
110110
with:
111111
# relative path to the place where source code with Dockerfile is located
112112
context: .

.github/workflows/release.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,18 @@ jobs:
2828
- name: Test environment variable
2929
run: echo ${{ env.RELEASE_VERSION }}
3030
- name: Check out GitHub repo
31-
uses: actions/checkout@v3
31+
uses: actions/checkout@v4
3232
with:
3333
submodules: recursive
3434
token: ${{ secrets.GH_TOKEN }}
3535
- name: Login to GitHub Container Registry
36-
uses: docker/login-action@v2
36+
uses: docker/login-action@v3
3737
with:
3838
registry: ${{ env.REGISTRY }}
3939
username: ${{ github.actor }}
4040
password: ${{ secrets.GH_TOKEN }}
4141
- name: Build image and push to GitHub Container Registry
42-
uses: docker/build-push-action@v4
42+
uses: docker/build-push-action@v5
4343
with:
4444
push: true
4545
context: .
@@ -73,7 +73,7 @@ jobs:
7373
goreleaser:
7474
runs-on: ubuntu-latest
7575
steps:
76-
- uses: actions/checkout@v3
76+
- uses: actions/checkout@v4
7777
with:
7878
fetch-depth: 0
7979
submodules: 'recursive'
@@ -85,7 +85,7 @@ jobs:
8585
run: |
8686
# List all nested directories
8787
find . -type f
88-
- uses: actions/setup-go@v4
88+
- uses: actions/setup-go@v5
8989
with:
9090
go-version: 1.21
9191
cache: true

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,7 @@ compage
1717
dist/
1818
/cosign.key
1919
/cosign.pub
20+
/myproject/*
21+
myproject/*
22+
cmd/artifacts/.DS_Store
23+
/__debug_bin*

.goreleaser.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ signs:
6363
- '--output-signature=${signature}'
6464
- '${artifact}'
6565
- "--yes"
66-
artifacts: checksum
66+
artifacts: all
6767
output: true
6868

6969
changelog:

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"mode": "debug",
99
"program": "${workspaceRoot}/main.go",
1010
"cwd": "${workspaceRoot}",
11-
"args": ["init", "--language","dotnet"]
11+
"args": ["pullTemplates"]
1212
}
1313
]
1414
}

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ To contribute code.
2727
## Regenerate the gRPC code from .proto files
2828
- Install below packages to regenerate the gRPC code.
2929
```shell
30-
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28
31-
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2
30+
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
31+
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
3232
```
3333
- Update below statement in ~/.zshrc or ~/.bashrc depending on the shell you are using.
3434
```shell

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
proto:
2+
if [ -d "gen/api/v1" ]; then rm -rf gen/api/v1; fi && mkdir -p ./gen && protoc --go_out=./gen --go-grpc_opt=paths=source_relative --go_opt=paths=source_relative --go-grpc_out=./gen api/v1/*.proto

api/v1/project.proto

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@ service ProjectService {
99
}
1010

1111
message GenerateCodeRequest {
12-
string projectName = 1;
13-
string projectJSON = 2;
14-
string gitRepositoryName = 3;
15-
string gitPlatformName = 4;
16-
string gitPlatformURL = 5;
17-
string gitPlatformUserName = 6;
18-
string projectMetadata = 7;
12+
string projectVersion = 1;
13+
string projectName = 2;
14+
string projectJSON = 3;
15+
string gitRepositoryName = 4;
16+
string gitPlatformName = 5;
17+
string gitPlatformURL = 6;
18+
string gitPlatformUserName = 7;
19+
string projectMetadata = 8;
1920
}
2021

2122
message GenerateCodeResponse{

cmd/artifacts/cosign/verifier.go

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
package cosign
2+
3+
import (
4+
"context"
5+
"github.com/fatih/color"
6+
"github.com/google/go-containerregistry/pkg/name"
7+
artifactUtils "github.com/intelops/compage/cmd/artifacts/utils"
8+
"github.com/sigstore/cosign/v2/cmd/cosign/cli/fulcio"
9+
"github.com/sigstore/cosign/v2/cmd/cosign/cli/options"
10+
"github.com/sigstore/cosign/v2/cmd/cosign/cli/rekor"
11+
"github.com/sigstore/cosign/v2/cmd/cosign/cli/verify"
12+
"github.com/sigstore/cosign/v2/pkg/cosign"
13+
sig "github.com/sigstore/cosign/v2/pkg/signature"
14+
"github.com/sigstore/sigstore/pkg/cryptoutils"
15+
log "github.com/sirupsen/logrus"
16+
)
17+
18+
func VerifyArtifact(ctx context.Context, key string) error {
19+
artifactURL := ctx.Value(artifactUtils.ContextKeyArtifactURL).(string)
20+
ref, err := name.ParseReference(artifactURL)
21+
if err != nil {
22+
log.Errorf("parsing reference: %v", err)
23+
return err
24+
}
25+
chopts := &cosign.CheckOpts{
26+
ClaimVerifier: cosign.SimpleClaimVerifier,
27+
}
28+
chopts.RekorClient, err = rekor.NewClient(options.DefaultRekorURL)
29+
if err != nil {
30+
log.Errorf("creating Rekor client: %v", err)
31+
return err
32+
}
33+
chopts.RootCerts, err = fulcio.GetRoots()
34+
if err != nil {
35+
log.Errorf("getting Fulcio root certs: %v", err)
36+
return err
37+
}
38+
ro := options.RegistryOptions{}
39+
chopts.RegistryClientOpts, err = ro.ClientOpts(ctx)
40+
if err != nil {
41+
log.Errorf("getting registry client options: %v", err)
42+
return err
43+
}
44+
chopts.IntermediateCerts, err = fulcio.GetIntermediates()
45+
if err != nil {
46+
log.Errorf("unable to get Fulcio intermediate certs: %s", err)
47+
return err
48+
}
49+
// Check if PubKey is supplied
50+
if key != "" {
51+
pub, err := sig.LoadPublicKey(ctx, key)
52+
if err != nil {
53+
log.Errorf("Error loading Pub Key: %v", err)
54+
return err
55+
}
56+
chopts.SigVerifier = pub
57+
}
58+
fulcioVerified := chopts.SigVerifier == nil
59+
chopts.RekorPubKeys, err = cosign.GetRekorPubs(ctx)
60+
if err != nil {
61+
log.Errorf("unable to get Rekor public keys: %s", err)
62+
return err
63+
}
64+
chopts.CTLogPubKeys, err = cosign.GetCTLogPubs(ctx)
65+
if err != nil {
66+
log.Errorf("unable to get CTLog public keys: %s", err)
67+
return err
68+
}
69+
sigs, bundleVerified, err := cosign.VerifyImageSignatures(context.Background(), ref, chopts)
70+
if err != nil {
71+
log.Errorf("verifying image signatures: %v", err)
72+
return err
73+
}
74+
75+
if bundleVerified {
76+
verify.PrintVerificationHeader(ctx, ref.String(), chopts, bundleVerified, fulcioVerified)
77+
for _, signature := range sigs {
78+
if cert, err := signature.Cert(); err == nil && cert != nil {
79+
ce := cosign.CertExtensions{Cert: cert}
80+
sub := ""
81+
if sans := cryptoutils.GetSubjectAlternateNames(cert); len(sans) > 0 {
82+
sub = sans[0]
83+
}
84+
color.Green("Certificate subject: %s", sub)
85+
if issuerURL := ce.GetIssuer(); issuerURL != "" {
86+
color.Green("Certificate issuer URL: %s", issuerURL)
87+
}
88+
if githubWorkflowTrigger := ce.GetCertExtensionGithubWorkflowTrigger(); githubWorkflowTrigger != "" {
89+
color.Green("GitHub Workflow Trigger: %s", githubWorkflowTrigger)
90+
}
91+
if githubWorkflowSha := ce.GetExtensionGithubWorkflowSha(); githubWorkflowSha != "" {
92+
color.Green("GitHub Workflow SHA: %s", githubWorkflowSha)
93+
}
94+
if githubWorkflowName := ce.GetCertExtensionGithubWorkflowName(); githubWorkflowName != "" {
95+
color.Green("GitHub Workflow Name: %s", githubWorkflowName)
96+
}
97+
if githubWorkflowRepository := ce.GetCertExtensionGithubWorkflowRepository(); githubWorkflowRepository != "" {
98+
color.Green("GitHub Workflow Repository: %s", githubWorkflowRepository)
99+
}
100+
if githubWorkflowRef := ce.GetCertExtensionGithubWorkflowRef(); githubWorkflowRef != "" {
101+
color.Green("GitHub Workflow Ref: %s", githubWorkflowRef)
102+
}
103+
}
104+
}
105+
}
106+
return nil
107+
}

0 commit comments

Comments
 (0)