-
Notifications
You must be signed in to change notification settings - Fork 0
152 lines (127 loc) · 4.55 KB
/
ci.yml
File metadata and controls
152 lines (127 loc) · 4.55 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
name: CI/CD Pipeline
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
workflow_dispatch:
permissions:
contents: read
security-events: write
jobs:
powershell-analysis:
name: PowerShell Script Analysis
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install PowerShell
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y wget apt-transport-https software-properties-common
wget -q https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
sudo apt-get update
sudo apt-get install -y powershell
- name: Install PSScriptAnalyzer
shell: pwsh
run: |
Install-Module -Name PSScriptAnalyzer -Force -Scope CurrentUser
- name: Run PSScriptAnalyzer
shell: pwsh
run: |
$results = Invoke-ScriptAnalyzer -Path ./scripts/ -Recurse -ReportSummary -Severity Warning,Error
if ($results) {
$results | Format-Table
Write-Output "PSScriptAnalyzer found issues. Please review and fix them."
exit 1
} else {
Write-Output "✅ No PSScriptAnalyzer issues found."
}
security-scan:
name: Security Scan
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Run security scan
shell: bash
run: |
echo "🔍 Scanning for sensitive data..."
# Check for actual hardcoded credentials (not just keywords)
if grep -r -E "(password|secret|key|token)\s*[:=]\s*['\"][a-zA-Z0-9]{8,}['\"]" --include="*.ps1" --include="*.md" . | grep -v -E "(example|placeholder|template|sample|test|YOUR_|EXAMPLE_)" | grep -q .; then
echo "❌ Hardcoded credentials detected!"
exit 1
else
echo "✅ No hardcoded credentials found."
fi
# Check for real sensitive file patterns
if find . -name "*.key" -o -name "*.pem" -o -name ".env" | grep -q .; then
echo "❌ Sensitive files detected!"
exit 1
else
echo "✅ No sensitive files found."
fi
documentation-check:
name: Documentation Check
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Check documentation
shell: bash
run: |
echo "📚 Checking documentation completeness..."
# Check if README exists and has required sections
if [ ! -f "README.md" ]; then
echo "❌ README.md is missing!"
exit 1
fi
# Check for required sections in README
required_sections=("Overview" "Quick Start" "Usage Guide")
for section in "${required_sections[@]}"; do
if ! grep -q "$section" README.md; then
echo "❌ Missing required section: $section"
exit 1
fi
done
echo "✅ Documentation check passed."
powershell-syntax:
name: PowerShell Syntax Check
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install PowerShell
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y wget apt-transport-https software-properties-common
wget -q https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
sudo apt-get update
sudo apt-get install -y powershell
- name: Syntax validation
shell: pwsh
run: |
$scriptFiles = Get-ChildItem -Path ./scripts/ -Filter "*.ps1" -Recurse
$syntaxErrors = 0
foreach ($file in $scriptFiles) {
Write-Output "Checking syntax: $($file.Name)"
$errors = $null
$null = [System.Management.Automation.PSParser]::Tokenize((Get-Content $file.FullName -Raw), [ref]$errors)
if ($errors) {
Write-Output "❌ Syntax errors in $($file.Name):"
$errors | ForEach-Object { Write-Output " - $($_.Message)" }
$syntaxErrors++
} else {
Write-Output "✅ $($file.Name) syntax OK"
}
}
if ($syntaxErrors -gt 0) {
Write-Output "❌ Found syntax errors in $syntaxErrors file(s)."
exit 1
} else {
Write-Output "✅ All PowerShell scripts have valid syntax."
}