Skip to content

Commit d23db0e

Browse files
committed
Merge branch 'main' into belay_main
* main: Enabled portage code scan Switch to just recording the default (origin) remote URL, isntead of 'owner'
2 parents f59ee6f + df6f187 commit d23db0e

3 files changed

Lines changed: 52 additions & 54 deletions

File tree

.github/workflows/code-scan.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Scan gatecheck
2+
run-name: "Scan the gatecheck codebase"
3+
permissions:
4+
contents: read
5+
checks: write
6+
packages: write
7+
on:
8+
workflow_dispatch:
9+
push:
10+
branches: [ '*' ]
11+
tags: [ '*' ]
12+
jobs:
13+
code_scan:
14+
runs-on: ubuntu-latest
15+
name: Portage Code Scan
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Run Portage CD Scans
20+
uses: easy-up/portage-cd-actions/image-build-scan-publish/docker@main
21+
with:
22+
image_build_enabled: 'false'
23+
image_scan_enabled: 'false'

.portage.yml

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,42 @@
11
# Base Configuration
22
version: "1"
3-
imageTag: "ghcr.io/easy-up/gatecheck:latest" # The full image tag for the target container image (e.g. my-org/my-app:latest)
3+
# gatecheck doesn't have an official Dockerfile
4+
# imageTag: "ghcr.io/easy-up/gatecheck:latest" # The full image tag for the target container image (e.g. my-org/my-app:latest)
45
artifactDir: "artifacts" # Directory for generated artifacts (e.g. ./artifacts)
56
gatecheckBundleFilename: "gatecheck-bundle.tar.gz" # Filename for the gatecheck bundle (e.g. gatecheck-bundle.tar.gz)
67

7-
# Image Build Configuration
8+
# Image Build Configuration (gatecheck doesn't have an official Dockerfile)
89
imageBuild:
910
enabled: false # Enable/Disable the image build pipeline (true/false)
10-
buildDir: "." # Build directory for image (e.g. ./cmd/portage)
11+
buildDir: "." # Build directory for image (e.g. ./cmd/portage)
1112
dockerfile: "Dockerfile" # Dockerfile to use (e.g. ./cmd/portage/Dockerfile)
12-
platform: "" # Target platform (e.g. linux/amd64, linux/arm64)
13-
target: "" # Target stage for multi-stage builds (e.g. build, test, publish)
14-
cacheTo: "" # Cache export location (e.g. type=local,dest=path)
15-
cacheFrom: "" # Cache import location (e.g. type=local,src=path)
16-
squashLayers: false # Whether to squash layers (true/false)
17-
args: {} # Build arguments (e.g. BUILD_ARGS=--build-arg=key=value)
13+
platform: "" # Target platform (e.g. linux/amd64, linux/arm64)
14+
target: "" # Target stage for multi-stage builds (e.g. build, test, publish)
15+
cacheTo: "" # Cache export location (e.g. type=local,dest=path)
16+
cacheFrom: "" # Cache import location (e.g. type=local,src=path)
17+
squashLayers: false # Whether to squash layers (true/false)
18+
args: {} # Build arguments (e.g. BUILD_ARGS=--build-arg=key=value)
1819

19-
# Image Scan Configuration
20+
# Image Scan Configuration (gatecheck doesn't have an official Dockerfile)
2021
imageScan:
21-
enabled: false # Enable/Disable the image scan pipeline (true/false)
22-
syftFilename: "syft-sbom-report.json" # Filename for the syft sbom report (e.g. syft-sbom-report.json)
23-
grypeConfigFilename: "" # Filename for the grype config (e.g. grype-config.json)
22+
enabled: false # Enable/Disable the image scan pipeline (true/false)
23+
syftFilename: "syft-sbom-report.json" # Filename for the syft sbom report (e.g. syft-sbom-report.json)
24+
grypeConfigFilename: "" # Filename for the grype config (e.g. grype-config.json)
2425
grypeFilename: "grype-vulnerability-report-full.json" # Filename for the grype vulnerability report (e.g. grype-vulnerability-report-full.json)
25-
clamavFilename: "clamav-virus-report.txt" # Filename for the clamav virus report (e.g. clamav-virus-report.txt)
26+
clamavFilename: "clamav-virus-report.txt" # Filename for the clamav virus report (e.g. clamav-virus-report.txt)
2627

2728
# Code Scan Configuration
2829
codeScan:
29-
enabled: true # Enable/Disable the code scan pipeline (true/false)
30+
enabled: true # Enable/Disable the code scan pipeline (true/false)
3031
gitleaksFilename: "gitleaks-secrets-report.json"
3132
gitleaksSrcDir: "."
3233
semgrepFilename: "semgrep-sast-report.json" # Filename for the semgrep sast report (e.g. semgrep-sast-report.json)
33-
semgrepRules: "p/default" # Semgrep rules to use (e.g. p/default)
34-
semgrepExperimental: false # Whether to use experimental semgrep rules (true/false)
35-
coverageFile: "" #"coverage/cobertura-coverage.xml" # Externally generated code coverage file
36-
semgrepSrcDir: "." # Target directory for semgrep scan (e.g. ./cmd/portage)
34+
semgrepRules: "p/default" # Semgrep rules to use (e.g. p/default)
35+
# This is overridden in the portage Dockerfile, but is set to false here for runs on local systems
36+
# where the standard Python semgrep is installed
37+
semgrepExperimental: false # Whether to use the experimental semgrep CLI (true/false)
38+
coverageFile: "" # "coverage/cobertura-coverage.xml" # Externally generated code coverage file
39+
semgrepSrcDir: "." # Target directory for semgrep scan (e.g. ./cmd/portage)
3740

3841
# Image Publish Configuration
3942
imagePublish:
@@ -42,9 +45,8 @@ imagePublish:
4245

4346
# Deploy Configuration
4447
deploy:
45-
enabled: true # Enable/Disable the deploy pipeline (true/false). When true, the .gatecheck.yml file is used, otherwise the default gatecheck config is used.
46-
gatecheckConfigFilename: ".custom-gatecheck.yml" # Filename for gatecheck config (e.g. gatecheck-config.json)
47-
submit: false # Whether to submit the artifacts to the configured API endpoint (true/false)
48+
enabled: false # Enable/Disable the deploy pipeline (true/false). When true, the .gatecheck.yml file is used, otherwise the default gatecheck config is used.
49+
gatecheckConfigFilename: ".custom-gatecheck.yml" # Filename for gatecheck config (e.g. gatecheck-config.json)
4850
successWebhooks:
49-
- url: "http://localhost:5168/Build/SubmitArtifacts" # Using the same endpoint from .custom-gatecheck.yml for consistency
50-
authorizationVar: "DEPLOY_WEBHOOK_AUTH_HEADER" # Environment variable containing the auth token
51+
- url: "https://belay-api.dev.holomuatech.online/Build/SubmitArtifacts" # Using the same endpoint from .custom-gatecheck.yml for consistency
52+
authorizationVar: "DEPLOY_WEBHOOK_AUTH_TOKEN" # Environment variable containing the auth token

pkg/archive/bundle.go

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ type GitContext struct {
5050
CommitMessage string `json:"commitMessage"`
5151
Status []GitFileStatus `json:"status"`
5252
Branch string `json:"branch"`
53-
Owner string `json:"owner"`
53+
Remote string `json:"remote"`
5454
}
5555

5656
type GitFileStatus struct {
@@ -113,14 +113,13 @@ func GetContext() (*GitContext, error) {
113113
slog.Debug("got git commit hash", "hash", strings.TrimSpace(string(commitHash)))
114114

115115
// Get repository owner from remote URL
116+
// TODO: make the name of the default remote configurable, use "origin" as the default
116117
gitCmd = exec.Command("git", "remote", "get-url", "origin")
117118
remoteURL, err := gitCmd.Output()
118119
if err != nil {
119120
slog.Error("failed to get remote URL", "error", err)
120121
return nil, fmt.Errorf("failed to get remote URL: %w", err)
121122
}
122-
owner := extractOwnerFromURL(string(remoteURL))
123-
slog.Debug("got repository owner", "owner", owner)
124123

125124
gitCmd = exec.Command("git", "show", "-s", "--format=%cI%n%B", "HEAD")
126125
commitDateAndMessageBytes, err := gitCmd.Output()
@@ -183,7 +182,7 @@ func GetContext() (*GitContext, error) {
183182
CommitMessage: strings.TrimSpace(commitMessage),
184183
Status: gitFileStatuses,
185184
Branch: strings.TrimSpace(string(branchName)),
186-
Owner: owner,
185+
Remote: string(remoteURL),
187186
}, nil
188187
}
189188

@@ -493,29 +492,3 @@ func UntarGzipBundle(src io.Reader, bundle *Bundle) error {
493492

494493
return nil
495494
}
496-
497-
// extractOwnerFromURL extracts the owner (user or org) from a git remote URL
498-
func extractOwnerFromURL(url string) string {
499-
url = strings.TrimSpace(url)
500-
501-
// Handle SSH URLs like git@github.com:owner/repo.git
502-
if strings.HasPrefix(url, "git@") {
503-
parts := strings.Split(url, ":")
504-
if len(parts) > 1 {
505-
ownerRepo := strings.Split(parts[1], "/")
506-
if len(ownerRepo) > 0 {
507-
return strings.TrimSpace(ownerRepo[0])
508-
}
509-
}
510-
}
511-
512-
// Handle HTTPS URLs like https://github.com/owner/repo.git
513-
parts := strings.Split(url, "/")
514-
for i, part := range parts {
515-
if strings.Contains(part, "github.com") && i+1 < len(parts) {
516-
return strings.TrimSpace(parts[i+1])
517-
}
518-
}
519-
520-
return ""
521-
}

0 commit comments

Comments
 (0)