-
Notifications
You must be signed in to change notification settings - Fork 0
191 lines (163 loc) · 6.72 KB
/
pr-validation.yml
File metadata and controls
191 lines (163 loc) · 6.72 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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
name: PR Validation
on:
pull_request:
branches: [main]
push:
branches: [main]
jobs:
validate-no-hardcoded-secrets:
name: Check for hardcoded credentials
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Scan for AWS account numbers
run: |
echo "Scanning for hardcoded 12-digit account numbers..."
FOUND=$(grep -rn '[0-9]\{12\}' \
--include="*.py" --include="*.sh" --include="*.ts" --include="*.yaml" --include="*.yml" --include="*.sql" \
--exclude-dir=node_modules --exclude-dir=.venv --exclude-dir=venv --exclude-dir=venv --exclude-dir=cdk.out --exclude-dir=__pycache__ \
--exclude-dir=generated-diagrams --exclude-dir=ash-output \
--exclude="poetry.lock" --exclude="package-lock.json" --exclude="cdk.context.json" \
| grep -v '{{ACCOUNT_ID}}\|{{REGION}}\|{{DATA_LAKE_BUCKET}}' \
| grep -v 'TRAINING_IMAGE_ACCOUNT\|AWS::AccountId\|self\.account\|this\.account\|get-caller-identity\|SourceAccount\|Stack.of' \
| grep -v 'FieldId\|HierarchyId' \
| grep -v '382416733822' \
| grep -v 'TOTAL_CUSTOMERS\|500000\|YEARLY_TARGETS' \
| grep -v 'TARGET_ACCOUNT_ID\|123456789012\|<ACCOUNT' \
| grep -v 'monitoring\.rds' \
|| true)
if [ -n "$FOUND" ]; then
echo "::error::Hardcoded account numbers found:"
echo "$FOUND"
exit 1
fi
echo "✓ No hardcoded account numbers found"
- name: Scan for hardcoded credentials
run: |
echo "Scanning for passwords, secrets, and RDS endpoints..."
FOUND=$(grep -rn \
-e 'DB_PASSWORD=.\+' \
-e "password='" \
-e '\.cluster-[a-z0-9]\+\.[a-z0-9-]\+\.rds\.amazonaws\.com' \
--include="*.py" --include="*.sh" --include="*.ts" --include="*.md" \
--exclude-dir=node_modules --exclude-dir=.venv --exclude-dir=venv --exclude-dir=cdk.out --exclude-dir=__pycache__ \
--exclude-dir=generated-diagrams --exclude-dir=ash-output \
| grep -v 'os\.environ\|secretsmanager\|SecretString\|get_secret\|DB_PASSWORD\}\|jq -r\|from-secrets-manager\|json\.load' \
| grep -v 'example\|placeholder\|<your-' \
|| true)
if [ -n "$FOUND" ]; then
echo "::error::Hardcoded credentials found:"
echo "$FOUND"
exit 1
fi
echo "✓ No hardcoded credentials found"
- name: Scan for personal references
run: |
echo "Scanning for personal usernames and local paths..."
FOUND=$(grep -rn \
-e '/Users/' \
-e '/home/' \
--include="*.py" --include="*.sh" --include="*.ts" --include="*.md" --include="*.yaml" --include="*.sql" --include="*.json" \
--exclude-dir=node_modules --exclude-dir=.venv --exclude-dir=venv --exclude-dir=cdk.out --exclude-dir=__pycache__ \
--exclude-dir=generated-diagrams --exclude-dir=ash-output \
--exclude="package-lock.json" --exclude="poetry.lock" \
|| true)
if [ -n "$FOUND" ]; then
echo "::error::Personal/local paths found:"
echo "$FOUND"
exit 1
fi
echo "✓ No personal references found"
validate-templates:
name: Validate template placeholders
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check JSON templates have placeholders
run: |
echo "Checking that JSON/SQL templates use placeholders..."
FILES=$(find . \
-path ./node_modules -prune -o \
-path ./.venv -prune -o \
-path ./cdk.out -prune -o \
-path ./generated-diagrams -prune -o \
\( -name "*.json" -o -name "*.sql" \) -print \
| xargs grep -l '{{ACCOUNT_ID}}\|{{REGION}}\|{{DATA_LAKE_BUCKET}}' 2>/dev/null || true)
if [ -n "$FILES" ]; then
echo "✓ Template files with placeholders:"
echo "$FILES" | while read f; do
COUNT=$(grep -c '{{' "$f")
echo " $f ($COUNT placeholders)"
done
fi
cdk-synth-cx360:
name: CDK Synth - Customer 360
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install CDK
run: npm install -g aws-cdk
- name: Install dependencies
working-directory: guidance-for-agentic-customer-360/deployment/cdk
run: npm install
- name: CDK Synth
working-directory: guidance-for-agentic-customer-360/deployment/cdk
run: npx tsc && cdk synth --all 2>&1 || echo "::warning::CDK synth requires AWS context (VPC lookup) - expected in CI without credentials"
cdk-synth-predictive:
name: CDK Synth - Predictive Maintenance
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install CDK
run: npm install -g aws-cdk
- name: Install dependencies
working-directory: guidance-for-predictive-maintenance/source/infrastructure
run: |
pip install poetry
poetry install --no-interaction
- name: CDK Synth
working-directory: guidance-for-predictive-maintenance/source/infrastructure
run: poetry run cdk synth --all 2>&1 || echo "::warning::CDK synth requires AWS context - expected in CI without credentials"
python-lint:
name: Python lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install linters
run: pip install flake8 bandit
- name: Flake8 - syntax and style
run: |
flake8 \
--max-line-length=150 \
--exclude=node_modules,.venv,venv,cdk.out,__pycache__,generated-diagrams,ash-output \
--select=E9,F63,F7,F82 \
.
- name: Bandit - security scan
run: |
bandit -r \
--exclude=node_modules,.venv,venv,cdk.out,__pycache__,generated-diagrams,ash-output \
--skip=B101 \
-ll \
. || true
cfn-validate:
name: Validate CloudFormation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Validate CloudFormation templates
run: |
pip install cfn-lint
echo "Linting CloudFormation templates..."
find platform-foundation/cloudformation -name "*.yaml" | while read f; do
echo " Checking: $f"
cfn-lint "$f" || true
done