Skip to content

Commit 32fa230

Browse files
Copilotnomeguy
andcommitted
Address code review feedback
- Fix typo: Polices -> Policies in test name - Add defensive length check before accessing line[0] in parsePolicy - Add defensive length check before accessing line[0] in parseRoles - Clarify log location in workflow documentation Co-authored-by: nomeguy <85475922+nomeguy@users.noreply.github.com>
1 parent c8bdf79 commit 32fa230

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

examples/workflow-example.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ EOF
4444

4545
## Step 2: Monitor Violations
4646

47-
Watch the logs to see what would be blocked:
47+
Watch the logs to see what would be blocked. Since the webhook runs as part of the controller:
4848

4949
```bash
5050
kubectl logs -n policywall-system deployment/policywall-controller -f | grep "DRY-RUN"
@@ -55,6 +55,8 @@ You'll see output like:
5555
W0116 01:19:54.677559 [DRY-RUN] Policy 'production-protection' violation: DELETE Pod/myapp in namespace production not allowed
5656
```
5757

58+
Note: The DRY-RUN violations are logged by the webhook handler within the controller pod.
59+
5860
## Step 3: Identify False Positives
5961

6062
Review the violations and adjust your policy if needed:

pkg/webhook/webhook.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ func parsePolicy(policyStr string) [][]string {
295295

296296
for _, line := range lines {
297297
line = trimSpace(line)
298-
if line == "" || line[0] == '#' {
298+
if len(line) == 0 || line[0] == '#' {
299299
continue
300300
}
301301

@@ -319,7 +319,7 @@ func parseRoles(policyStr string) [][]string {
319319

320320
for _, line := range lines {
321321
line = trimSpace(line)
322-
if line == "" || line[0] == '#' {
322+
if len(line) == 0 || line[0] == '#' {
323323
continue
324324
}
325325

pkg/webhook/webhook_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ m = r.sub == p.sub && r.obj == p.obj && r.act == p.act`,
359359
}
360360
}
361361

362-
func TestWebhookServer_MultiplePolices(t *testing.T) {
362+
func TestWebhookServer_MultiplePolicies(t *testing.T) {
363363
server := NewWebhookServer()
364364

365365
// Add a dry-run policy

0 commit comments

Comments
 (0)