Skip to content

Commit 849f51d

Browse files
committed
Init
0 parents  commit 849f51d

File tree

7 files changed

+103
-0
lines changed

7 files changed

+103
-0
lines changed

.github/workflows/go-vuln-scan.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Go Vulnerability Scan
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
10+
11+
jobs:
12+
check-go-version:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v3
17+
18+
- name: Run Go Vulnerability Scanner
19+
uses: ./

.vscode/settings.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"cSpell.words": [
3+
"govulncheck"
4+
]
5+
}

Dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM golang:1.23
2+
3+
WORKDIR /app
4+
5+
RUN go install golang.org/x/vuln/cmd/govulncheck@latest
6+
7+
COPY . .
8+
9+
RUN go build -o main main.go
10+
11+
RUN ls -l /app
12+
13+
ENTRYPOINT ["/app/main"]

README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Go Vulnerability Scanner GitHub Action 🚀
2+
3+
Easily scan your Go projects for known vulnerabilities using the govulncheck tool provided by golang.org/x/vuln. This GitHub Action integrates seamlessly into your CI/CD pipeline, ensuring your dependencies are up-to-date and free from security risks.
4+
5+
6+
## Usage
7+
Add the following workflow file to your project:
8+
9+
.github/workflows/go-vuln-scan.yml:
10+
11+
```
12+
name: Go Vulnerability Scan
13+
14+
on:
15+
push:
16+
branches:
17+
- main
18+
pull_request:
19+
branches:
20+
- main
21+
22+
jobs:
23+
vuln-scan:
24+
name: Run Go Vulnerability Scanner
25+
runs-on: ubuntu-latest
26+
27+
steps:
28+
- name: Checkout Code
29+
uses: actions/checkout@v4
30+
31+
- name: Run Go Vulnerability Scanner
32+
uses: debug-ing/[email protected]
33+
```

action.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: "Go Vulnerability Scanner"
2+
description: "Scans Go dependencies for security vulnerabilities using govulncheck"
3+
author: "Mahdi Mohammadi"
4+
5+
runs:
6+
using: "docker"
7+
image: "Dockerfile"
8+
9+
branding:
10+
icon: "shield"
11+
color: "red"

go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module github.com/debug-ing/go-vuln-scanner
2+
3+
go 1.22.3

main.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"os"
6+
"os/exec"
7+
)
8+
9+
func main() {
10+
fmt.Println("Starting Go Dependency Vulnerability Scan...")
11+
cmd := exec.Command("govulncheck", "./...")
12+
cmd.Stdout = os.Stdout
13+
cmd.Stderr = os.Stderr
14+
if err := cmd.Run(); err != nil {
15+
fmt.Println("Error during vulnerability scan:", err)
16+
os.Exit(1)
17+
}
18+
fmt.Println("Vulnerability scan completed successfully!")
19+
}

0 commit comments

Comments
 (0)