Skip to content

Commit 37c7ce7

Browse files
committed
Updated
1 parent 1e25ceb commit 37c7ce7

File tree

2 files changed

+61
-5
lines changed

2 files changed

+61
-5
lines changed

.github/workflows/actions.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: CVE Check
2+
3+
on:
4+
schedule:
5+
- cron: '*/10 * * * *'
6+
# push:
7+
# branches:
8+
# - main
9+
10+
# Actions project permission
11+
permissions:
12+
contents: write
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Check out repository
20+
uses: actions/checkout@v3
21+
22+
- name: Set up Go
23+
uses: actions/setup-go@v4
24+
with:
25+
go-version: '1.23.0' # Specify the version of Go you want to use
26+
27+
- name: Run CVE mapping command
28+
env:
29+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30+
run: |
31+
echo '"CVE-2024-"' | go run cvemapping.go -github-token "$GITHUB_TOKEN" -page 1 -year 2024
32+
33+
- name: Commit and push changes if there are any
34+
run: |
35+
git config --global user.name 'GitHub Actions'
36+
git config --global user.email 'actions@users.noreply.github.com'
37+
git add .
38+
39+
# Check if there are changes before committing
40+
if ! git diff --cached --exit-code; then
41+
IST_DATE=$(TZ='Asia/Kolkata' date +'%a %b %d %H:%M:%S IST %Y')
42+
git commit -m "Updated List: $IST_DATE"
43+
git push
44+
else
45+
echo "No changes to commit"
46+
fi

cvemapping.go

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,13 +193,23 @@ func cloneRepo(cloneURL string, cveName string, stargazersCount int, year string
193193

194194
fmt.Printf("[CLONED] [%d] %s into %s\n", stargazersCount, cloneURL, cloneDir)
195195

196-
// Remove the .git directory
197-
gitDir := fmt.Sprintf("%s/.git", cloneDir)
198-
if err := os.RemoveAll(gitDir); err != nil {
199-
return fmt.Errorf("failed to remove .git directory: %w", err)
196+
// List of items to remove
197+
itemsToRemove := []string{
198+
".git",
199+
".github",
200+
".gitignore",
201+
".gitattributes",
202+
"LICENSE",
200203
}
201204

202-
fmt.Printf("[REMOVED .git] from %s\n", cloneDir)
205+
// Remove the .git directory and other specified files/directories
206+
for _, item := range itemsToRemove {
207+
itemPath := filepath.Join(cloneDir, item)
208+
if err := os.RemoveAll(itemPath); err != nil {
209+
return fmt.Errorf("failed to remove %s: %w", item, err)
210+
}
211+
fmt.Printf("[REMOVED %s] from %s\n", item, cloneDir)
212+
}
203213

204214
// Check directory size and file count
205215
dirSize, fileCount, err := getDirSizeAndFileCount(cloneDir)

0 commit comments

Comments
 (0)