-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add json schema generation (#1264)
## Description Adds json schemas using the quicktype generation from KFC. In addition has a post-processing step using yq to make the schema behave strictly. ## Related Issue Fixes #1263 ## Type of change - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [x] Other (security config, docs update, etc) ## Steps to Validate This doesn't work great within core, but you can test by pointing to the schema from this branch, updating the `.vscode/settings.json` file to: ```json "https://raw.githubusercontent.com/defenseunicorns/uds-core/refs/heads/json-schema/schemas/package-v1alpha1.schema.json": [ "**/uds-package.yaml", "**/package.yaml" ], "https://raw.githubusercontent.com/defenseunicorns/uds-core/refs/heads/json-schema/schemas/exemption-v1alpha1.schema.json": [ "**/uds-exemption.yaml", "**/exemptions.yaml", "**/exemption.yaml" ], ``` Open up a package / exemption file. You may need to change some settings in the bottom right to ensure VSCode uses `yaml` instead of `helm-template` for the file. Then try adding/modifying fields to ensure schema violations are shown. ## Checklist before merging - [x] Test, docs, adr added or updated as needed - [x] [Contributor Guide](https://github.com/defenseunicorns/uds-template-capability/blob/main/CONTRIBUTING.md) followed
- Loading branch information
Showing
6 changed files
with
1,245 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"$ref": "#/definitions/Exemption", | ||
"definitions": { | ||
"Exemption": { | ||
"type": "object", | ||
"additionalProperties": {}, | ||
"properties": { | ||
"spec": { | ||
"$ref": "#/definitions/Spec" | ||
} | ||
}, | ||
"required": [], | ||
"title": "Exemption" | ||
}, | ||
"Spec": { | ||
"type": "object", | ||
"additionalProperties": false, | ||
"properties": { | ||
"exemptions": { | ||
"type": "array", | ||
"items": { | ||
"$ref": "#/definitions/ExemptionElement" | ||
}, | ||
"description": "Policy exemptions" | ||
} | ||
}, | ||
"required": [ | ||
"exemptions" | ||
], | ||
"title": "Spec" | ||
}, | ||
"ExemptionElement": { | ||
"type": "object", | ||
"additionalProperties": false, | ||
"properties": { | ||
"description": { | ||
"type": "string", | ||
"description": "Reasons as to why this exemption is needed" | ||
}, | ||
"matcher": { | ||
"$ref": "#/definitions/Matcher", | ||
"description": "Resource to exempt (Regex allowed for name)" | ||
}, | ||
"policies": { | ||
"type": "array", | ||
"items": { | ||
"$ref": "#/definitions/Policy" | ||
}, | ||
"description": "A list of policies to override" | ||
}, | ||
"title": { | ||
"type": "string", | ||
"description": "title to give the exemption for reporting purposes" | ||
} | ||
}, | ||
"required": [ | ||
"matcher", | ||
"policies" | ||
], | ||
"title": "ExemptionElement" | ||
}, | ||
"Matcher": { | ||
"type": "object", | ||
"additionalProperties": false, | ||
"properties": { | ||
"kind": { | ||
"$ref": "#/definitions/Kind" | ||
}, | ||
"name": { | ||
"type": "string" | ||
}, | ||
"namespace": { | ||
"type": "string" | ||
} | ||
}, | ||
"required": [ | ||
"name", | ||
"namespace" | ||
], | ||
"title": "Matcher", | ||
"description": "Resource to exempt (Regex allowed for name)" | ||
}, | ||
"Kind": { | ||
"type": "string", | ||
"enum": [ | ||
"pod", | ||
"service" | ||
], | ||
"title": "Kind" | ||
}, | ||
"Policy": { | ||
"type": "string", | ||
"enum": [ | ||
"DisallowHostNamespaces", | ||
"DisallowNodePortServices", | ||
"DisallowPrivileged", | ||
"DisallowSELinuxOptions", | ||
"DropAllCapabilities", | ||
"RequireNonRootUser", | ||
"RestrictCapabilities", | ||
"RestrictExternalNames", | ||
"RestrictHostPathWrite", | ||
"RestrictHostPorts", | ||
"RestrictProcMount", | ||
"RestrictSeccomp", | ||
"RestrictSELinuxType", | ||
"RestrictVolumeTypes" | ||
], | ||
"title": "Policy" | ||
} | ||
} | ||
} |
Oops, something went wrong.