Skip to content

add pydantic model for parser #73

add pydantic model for parser

add pydantic model for parser #73

Workflow file for this run

name: check hub
on:
push:
branches: [ main ]
pull_request:
branches:
- main
jobs:
yaml-schema-validation:
runs-on: ubuntu-latest
steps:
- name: checkout repo
uses: actions/checkout@v3
- name: checkout hub
uses: actions/checkout@v3
with:
repository: 'crowdsecurity/hub'
path: hub
- name: transform to json all parsers/scenarios/collections/postovfw
uses: mikefarah/yq@master
with:
cmd: find . -path ./.tests -prune -o -name "*"yaml -exec sh -c 'yq -o=json {} > $(dirname {})/$(basename {} .yaml).json' \;
- name: transform to json schema
run: |
apt-get install -y pip3
pip3 install pydantic
python -c 'from models.parser import Parser; import json; out_file=open("parser_schema.json","w"); json.dump(Parser.model_json_schema(),out_file)'
- name: validate parsers against schema
run: |
go install github.com/santhosh-tekuri/jsonschema/cmd/jv@latest
for ITEM in ./hub/parsers/*/*/*.json; do echo $ITEM && ~/go/bin/jv parser_schema.json $ITEM ; done
- name: validate scenarios against schema
run: |
for ITEM in ./hub/scenarios/*/*.json; do echo $ITEM && ~/go/bin/jv scenario_schema.json $ITEM ; done
- name: validate postoverflows against schema
run: |
for ITEM in ./hub/postoverflows/*/*/*.json; do echo $ITEM && ~/go/bin/jv parser_schema.json $ITEM ; done
- name: validate parsers against schema
run: |
for ITEM in ./hub/collections/*/*.json; do echo $ITEM && ~/go/bin/jv collection_schema.json $ITEM ; done