-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Finished YAML validation pre-commit hook
- Streamlined the YAML validation process by consolidating it into a shared function. - Improved error messaging for enhanced clarity. - Established a new function, loadSchema, to facilitate schema loading and unmarshalling from a YAML file. - Enhanced ValidateYAML to accommodate schema path input and extended support for directory-wide YAML file validation. - Revised the validateAllYAML function to furnish comprehensive error messages and enhanced logging. - Elevated error handling for YAML validation by providing informative error messages. - Augmented the inspectAndValidate function to adeptly manage nested SubTTPSteps and validate referenced files. - Implemented custom validation to ascertain the presence of the "name" property when "ttp" is declared in a step. This commit amplifies the effectiveness of YAML file validation, ensuring strict adherence to the schema. Introduces a pre-commit hook mechanism to preemptively thwart the commitment of non-conforming YAML files.
- Loading branch information
Showing
5 changed files
with
263 additions
and
209 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,161 +1,130 @@ | ||
--- | ||
TTP: | ||
type: object | ||
properties: | ||
name: | ||
type: string | ||
description: | ||
type: string | ||
required: true | ||
mitre: | ||
$ref: "#/definitions/Mitre" | ||
env: | ||
type: object | ||
additionalProperties: | ||
type: string | ||
steps: | ||
type: array | ||
items: | ||
type: object | ||
oneOf: | ||
- $ref: "#/definitions/FileStep" | ||
- $ref: "#/definitions/BasicStep" | ||
- $ref: "#/definitions/SubTTPStep" | ||
- $ref: "#/definitions/EditStep" | ||
args: | ||
type: array | ||
items: | ||
$ref: "#/definitions/Spec" | ||
definitions: | ||
TTP: | ||
type: object | ||
properties: | ||
name: | ||
type: string | ||
description: | ||
type: string | ||
mitre: | ||
$ref: "#/definitions/Mitre" | ||
steps: | ||
type: array | ||
items: | ||
oneOf: | ||
- $ref: "#/definitions/SubTTPStep" | ||
- $ref: "#/definitions/BasicStep" | ||
- $ref: "#/definitions/EditStep" | ||
args: | ||
type: array | ||
items: | ||
$ref: "#/definitions/Spec" | ||
required: | ||
- name | ||
- description | ||
- steps | ||
|
||
Act: | ||
type: object | ||
properties: | ||
if: | ||
type: string | ||
env: | ||
type: object | ||
additionalProperties: | ||
type: string | ||
name: | ||
type: string | ||
required: true | ||
outputs: | ||
type: object | ||
additionalProperties: | ||
$ref: "#/definitions/Spec" | ||
Mitre: | ||
type: object | ||
properties: | ||
tactics: | ||
type: array | ||
items: | ||
type: string | ||
techniques: | ||
type: array | ||
items: | ||
type: string | ||
subtechniques: | ||
type: array | ||
items: | ||
type: string | ||
|
||
Mitre: | ||
type: object | ||
properties: | ||
tactics: | ||
type: array | ||
items: | ||
type: string | ||
techniques: | ||
type: array | ||
items: | ||
BasicStep: | ||
type: object | ||
properties: | ||
name: | ||
type: string | ||
subtechniques: | ||
type: array | ||
items: | ||
inline: | ||
type: string | ||
cleanup: | ||
$ref: "#/definitions/CleanupAct" | ||
args: | ||
type: array | ||
items: | ||
type: string | ||
required: | ||
- name | ||
- inline | ||
|
||
FileStep: | ||
type: object | ||
properties: | ||
act: | ||
$ref: "#/definitions/Act" | ||
file: | ||
type: string | ||
executor: | ||
type: string | ||
cleanup: | ||
$ref: "#/definitions/CleanupAct" | ||
args: | ||
type: array | ||
items: | ||
CleanupAct: | ||
type: object | ||
properties: | ||
inline: | ||
type: string | ||
required: | ||
- inline | ||
|
||
BasicStep: | ||
type: object | ||
properties: | ||
act: | ||
$ref: "#/definitions/Act" | ||
executor: | ||
type: string | ||
inline: | ||
type: string | ||
args: | ||
type: array | ||
items: | ||
type: string | ||
cleanup: | ||
type: string | ||
|
||
SubTTPStep: | ||
type: object | ||
properties: | ||
act: | ||
$ref: "#/definitions/Act" | ||
ttp: | ||
type: string | ||
args: | ||
type: object | ||
additionalProperties: | ||
SubTTPStep: | ||
type: object | ||
properties: | ||
name: | ||
type: string | ||
ttp: | ||
type: string | ||
args: | ||
type: object | ||
additionalProperties: | ||
type: string | ||
required: | ||
- name | ||
- ttp | ||
|
||
Edit: | ||
type: object | ||
properties: | ||
old: | ||
type: string | ||
new: | ||
type: string | ||
regexp: | ||
type: boolean | ||
|
||
EditStep: | ||
type: object | ||
properties: | ||
act: | ||
$ref: "#/definitions/Act" | ||
edit_file: | ||
type: string | ||
edits: | ||
type: array | ||
items: | ||
$ref: "#/definitions/Edit" | ||
backup_file: | ||
type: string | ||
|
||
CleanupAct: | ||
type: object | ||
properties: | ||
if: | ||
type: string | ||
env: | ||
type: object | ||
additionalProperties: | ||
type: string | ||
name: | ||
type: string | ||
required: true | ||
outputs: | ||
type: object | ||
additionalProperties: | ||
EditStep: | ||
type: object | ||
properties: | ||
name: | ||
type: string | ||
edit_file: | ||
type: string | ||
backup_file: | ||
type: string | ||
edits: | ||
type: array | ||
items: | ||
$ref: "#/definitions/Spec" | ||
$ref: "#/definitions/Edit" | ||
required: | ||
- name | ||
- edit_file | ||
- backup_file | ||
- edits | ||
|
||
Spec: | ||
type: object | ||
properties: | ||
name: | ||
type: string | ||
required: true | ||
type: | ||
type: string | ||
default: | ||
type: string | ||
description: | ||
type: string | ||
Edit: | ||
type: object | ||
properties: | ||
old: | ||
type: string | ||
new: | ||
type: string | ||
regexp: | ||
type: string | ||
required: | ||
- old | ||
- new | ||
- regexp | ||
|
||
Spec: | ||
type: object | ||
properties: | ||
name: | ||
type: string | ||
type: | ||
type: string | ||
default: | ||
type: string | ||
description: | ||
type: string | ||
required: | ||
- name | ||
- type |
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
Oops, something went wrong.