docs: Validate ecosystem keys (#6522)

At the moment we have some entries with . chars in their ids, this makes
the hugo page look up break, so now these are validated to be
sausage-case-values.

Signed-off-by: Charlie Egan <charlie@styra.com>
This commit is contained in:
Charlie Egan
2024-01-11 13:42:43 +00:00
committed by GitHub
parent 63e1877c48
commit 35da78715d
7 changed files with 88 additions and 5 deletions
+42
View File
@@ -6,6 +6,20 @@ import future.keywords.in
allowed_image_extensions := ["png", "svg"]
# check that each integration key is valid
deny contains result if {
some path, _ in input.integrations
id := split(path, "/")[2]
not regex.match("^([a-z0-9-]+)$", id)
result := {
"key": "key",
"message": sprintf("integration %s has an invalid key characters, change filename to lowercase and replace spaces with dashes", [id]),
}
}
# check that all integrations have an image
deny contains result if {
some path, integration in input.integrations
@@ -161,6 +175,34 @@ deny contains result if {
}
}
# check that each organization key is valid
deny contains result if {
some path, _ in input.organizations
id := split(path, "/")[2]
not regex.match("^([a-z0-9-]+)$", id)
result := {
"key": "key",
"message": sprintf("organization %s has an invalid key characters, change filename to lowercase and replace spaces with dashes", [id]),
}
}
# check that each software key is valid
deny contains result if {
some path, _ in input.softwares
id := split(path, "/")[2]
not regex.match("^([a-z0-9-]+)$", id)
result := {
"key": "key",
"message": sprintf("software %s has an invalid key characters, change filename to lowercase and replace spaces with dashes", [id]),
}
}
# check that each software has at least one integration
deny contains result if {
some path, software in input.softwares
+42
View File
@@ -26,6 +26,20 @@ print_if(false, key, expected, output) := false {
print("Got:", messages_for_key(key, output))
}
test_integration_has_valid_key {
output := data.integrations.deny with input as {"integrations": {"/integrations/in.valid/": {"link": "https://example.com/", "title": "Example"}}}
key := "key"
got := messages_for_key(key, output)
message := "integration in.valid has an invalid key characters, change filename to lowercase and replace spaces with dashes"
result := message in got
print_if(result, key, message, output)
}
test_integration_has_required_fields_missing {
output := data.integrations.deny with input as {"integrations": {"/integrations/regal/": {}}}
@@ -274,6 +288,20 @@ test_organization_has_required_fields_present {
print_if(result, key, false, output)
}
test_organization_has_valid_key {
output := data.integrations.deny with input as {"organizations": {"/organizations/sty.ra/": {"link": "https://styra.com/", "title": "Styra"}}}
key := "key"
got := messages_for_key(key, output)
message := "organization sty.ra has an invalid key characters, change filename to lowercase and replace spaces with dashes"
result := message in got
print_if(result, key, message, output)
}
test_organization_has_one_or_more_integrations_none {
output := data.integrations.deny with input as {"organizations": {"/organizations/foobar/": {}}, "integrations": {}}
@@ -332,3 +360,17 @@ test_software_has_one_or_more_integrations_one {
print_if(result, key, false, output)
}
test_software_has_valid_key {
output := data.integrations.deny with input as {"softwares": {"/softwares/in.valid/": {"link": "https://example.com/", "title": "Example"}}}
key := "key"
got := messages_for_key(key, output)
message := "software in.valid has an invalid key characters, change filename to lowercase and replace spaces with dashes"
result := message in got
print_if(result, key, message, output)
}
@@ -6,7 +6,7 @@ labels:
code:
- https://github.com/build-security/OPA-AspDotNetCore-Middleware
inventors:
- build.security
- build-security
---
Use ASP.NET Core to create web apps and services that are fast, secure, cross-platform, and cloud-based.
OPA can be used to implement authorization policies for APIs used in the ASP.NET Core framework.
@@ -6,7 +6,7 @@ labels:
code:
- https://github.com/build-security/opa-express-middleware
inventors:
- build.security
- build-security
software:
- nodejsexpress
docs_features:
@@ -19,4 +19,3 @@ docs_features:
---
Express is a minimal and flexible Node.js web application framework that provides a robust set of features for web and mobile applications.
OPA can be used to implement authorization policies for APIs used in the express framework.
@@ -12,7 +12,7 @@ code:
- https://github.com/segrax/openpolicyagent
- https://github.com/build-security/opa-symfony-middleware
inventors:
- build.security
- build-security
docs_features:
rest-api-integration:
note: |
@@ -17,7 +17,7 @@ tutorials:
- https://www.baeldung.com/spring-security-authorization-opa
inventors:
- styra
- build.security
- build-security
- bisnode
- alertavert
docs_features: