Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove all punctuation from anchors in policies.md
Browse files Browse the repository at this point in the history
zephyrdb committed Dec 17, 2024
1 parent fdfe524 commit 566bc25
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion examples/policies-no-rego.md
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@
* [P2001: Images must not use the latest tag](#p2001-images-must-not-use-the-latest-tag)
* [P2002: Containers must define resource constraints](#p2002-containers-must-define-resource-constraints)
* [P2005: Roles must not allow use of privileged PodSecurityPolicies](#p2005-roles-must-not-allow-use-of-privileged-podsecuritypolicies)
* [P2006: Tenants' containers must not run as privileged](#p2006-tenants'-containers-must-not-run-as-privileged)
* [P2006: Tenants' containers must not run as privileged](#p2006-tenants-containers-must-not-run-as-privileged)

## Warnings

2 changes: 1 addition & 1 deletion examples/policies.md
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@
* [P2001: Images must not use the latest tag](#p2001-images-must-not-use-the-latest-tag)
* [P2002: Containers must define resource constraints](#p2002-containers-must-define-resource-constraints)
* [P2005: Roles must not allow use of privileged PodSecurityPolicies](#p2005-roles-must-not-allow-use-of-privileged-podsecuritypolicies)
* [P2006: Tenants' containers must not run as privileged](#p2006-tenants'-containers-must-not-run-as-privileged)
* [P2006: Tenants' containers must not run as privileged](#p2006-tenants-containers-must-not-run-as-privileged)

## Warnings

9 changes: 8 additions & 1 deletion internal/commands/document.go
Original file line number Diff line number Diff line change
@@ -186,7 +186,14 @@ func getDocumentation(path string, outputDirectory string) (map[rego.Severity][]
}

anchor := strings.ToLower(strings.ReplaceAll(documentTitle, " ", "-"))
anchor = strings.ReplaceAll(anchor, ":", "")
// Tab and all ASCII punctuation except - and _
punctReplacer := strings.NewReplacer(
"\t", "", "!", "", "\"", "", "#", "", "$", "", "%", "", "&", "", "'", "", "(", "", ")", "",
"*", "", "+", "", ",", "", ".", "", "/", "", ":", "", ";", "", "<", "", "=", "", ">", "",
"?", "", "@", "", "[", "", "\\", "", "]", "", "^", "", "`", "", "{", "", "|", "", "}", "",
"~", "",
)
anchor = punctReplacer.Replace(anchor)

legacyMatchers, err := policy.Matchers()
if err != nil {

0 comments on commit 566bc25

Please sign in to comment.