Repository navigation
Expand file tree
/
Copy pathaction.yml
More file actions
98 lines (96 loc) · 3.3 KB
/
Copy pathaction.yml
File metadata and controls
98 lines (96 loc) · 3.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
name: "CredSweeper action"
description: "CredSweeper checks files"
author: "r.babenko@samsung.com"
branding:
icon: "terminal"
color: "gray-dark"
inputs:
python_version:
description: "Python Version. 3.11 - default"
default: "3.11"
required: false
path:
description: "Path to scan"
required: true
severity:
description: "Minimal severity rule filter"
default: "INFO"
required: false
report:
description: "CredSweeper report in JSON format"
default: "output.json"
required: false
hashed:
description: "Report output is hashed by default"
default: "true"
required: false
error:
description: "Exit with the common error code if credentials are detected"
default: "true"
required: false
subtext:
description: "Reduce line in report around found value"
default: "false"
required: false
runs:
using: "composite"
steps:
- name: Setup Python
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0 - 2026.06.24
with:
python-version: ${{ inputs.python_version }}
- name: Install latest CredSweeper
shell: bash
run: python -m pip install --upgrade pip credsweeper
- name: Run CredSweeper
shell: python
env:
WORKSPACE: ${{ github.workspace }}
path: ${{ inputs.path }}
severity: ${{ inputs.severity }}
report: ${{ inputs.report }}
hashed: ${{ inputs.hashed }}
error: ${{ inputs.error }}
subtext: ${{ inputs.subtext }}
run: |
import os
import sys
from multiprocessing import freeze_support
from pathlib import Path
from credsweeper.main import main
workspace = Path(os.environ["WORKSPACE"]).resolve()
if not workspace.exists():
print(f"ERROR: Workspace does not exist: {workspace}", file=sys.stderr)
sys.exit(1)
scan_path = (workspace / os.environ["path"]).resolve()
if not scan_path.exists():
print(f"ERROR: Scan path does not exist: {scan_path}", file=sys.stderr)
sys.exit(1)
try:
scan_path.relative_to(workspace)
except ValueError:
print(f"ERROR: Scan path must be within workspace", file=sys.stderr)
sys.exit(1)
report_path = (workspace / os.environ["report"]).resolve()
try:
report_path.relative_to(workspace)
except ValueError:
print(f"ERROR: Report path must be within workspace", file=sys.stderr)
sys.exit(1)
report_path.parent.mkdir(parents=True, exist_ok=True)
if __name__ == '__main__':
freeze_support()
argv=[
"--banner",
"--log", "INFO",
"--no-color",
"--no-stdout",
"--error" if "true" == os.environ["error"].lower() else "--no-error",
"--hashed" if "true" == os.environ["hashed"].lower() else "--no-hashed",
"--subtext" if "true" == os.environ["subtext"].lower() else "--no-subtext",
"--save-json", str(os.environ["report"]),
"--severity", str(os.environ["severity"]),
"--path", str(os.environ["path"]),
]
exit_code=main(argv)
sys.exit(exit_code)