|
1 | | -# name: pull_request_target |
2 | | - |
3 | | -# on: |
4 | | -# pull_request_target: |
5 | | -# types: [opened, synchronize] |
6 | | - |
7 | | -# jobs: |
8 | | -# send-json-files: |
9 | | -# runs-on: ubuntu-latest |
10 | | -# steps: |
11 | | -# - name: Checkout PR code |
12 | | -# uses: actions/checkout@v3 |
13 | | -# with: |
14 | | -# fetch-depth: 0 |
15 | | -# ref: ${{ github.event.pull_request.head.ref }} |
16 | | -# repository: ${{ github.event.pull_request.head.repo.full_name }} |
17 | | - |
18 | | -# - name: Get changed JSON files and contents to send to API endpoint |
19 | | -# id: prepare_json_files |
20 | | -# run: | |
21 | | -# echo "Collecting changed JSON files..." |
22 | | -# BASE="${{ github.event.pull_request.base.sha }}" |
23 | | -# HEAD="${{ github.event.pull_request.head.sha }}" |
24 | | - |
25 | | -# mapfile -t files < <(git diff --name-only "$BASE" "$HEAD" | grep '\.json$') |
26 | | -# echo "Changed JSON files: ${files[@]}" |
27 | | - |
28 | | -# if [ ${#files[@]} -eq 0 ]; then |
29 | | -# echo "No JSON files changed in this PR." |
30 | | -# echo "JSON_PAYLOAD_PATH=empty" >> $GITHUB_ENV |
31 | | -# exit 0 |
32 | | -# fi |
33 | | - |
34 | | -# json_array="[" |
35 | | -# for file in "${files[@]}"; do |
36 | | -# if [ -f "$file" ]; then |
37 | | -# if jq -e . "$file" > /dev/null 2>&1; then |
38 | | -# content=$(jq -c . < "$file") |
39 | | -# json_array+="{\"filename\": \"${file}\", \"content\": $content}," |
40 | | -# else |
41 | | -# echo "❌ Invalid JSON structure in file: $file" |
42 | | -# exit 1 |
43 | | -# fi |
44 | | -# fi |
45 | | -# done |
46 | | -# json_array="${json_array%,}]" |
47 | | -# echo "$json_array" > files_payload.json |
48 | | -# echo "JSON_PAYLOAD_PATH=files_payload.json" >> $GITHUB_ENV |
49 | | - |
50 | | -# - name: Send JSON files to API and check response |
51 | | -# if: env.JSON_PAYLOAD_PATH != 'empty' |
52 | | -# env: |
53 | | -# API_URL: https://valid1-e2akhdekg6a7a2ch.canadacentral-01.azurewebsites.net/ |
54 | | -# run: | |
55 | | -# echo "Sending JSON payload to API" |
56 | | -# response=$(curl -s -X POST "$API_URL" \ |
57 | | -# -H "Content-Type: application/json" \ |
58 | | -# --data-binary "@$JSON_PAYLOAD_PATH") |
59 | | -# status=$(jq -r '.status' <<< "$response") |
60 | | -# message=$(jq -r '.message' <<< "$response") |
61 | | -# if [ "$status" != "passed" ]; then |
62 | | -# echo "❌ Test Fail : $message" |
63 | | -# exit 1 |
64 | | -# fi |
65 | | -# echo "✅ $message" |
| 1 | +contexts: |
| 2 | + - name: Body |
| 3 | + when: "True" |
| 4 | + require: |
| 5 | + - type |
| 6 | + - kind |
| 7 | + - name |
| 8 | + - apiVersion |
| 9 | + - location |
| 10 | + - properties.connectorUiConfig |
| 11 | + |
| 12 | + - name: type |
| 13 | + when : "exists('type')" |
| 14 | + equals: |
| 15 | + type: "Microsoft.SecurityInsights/dataConnectorDefinitions" |
| 16 | + |
| 17 | + - name: connectorUiConfig |
| 18 | + when: "exists('properties.connectorUiConfig')" |
| 19 | + require: |
| 20 | + - properties.connectorUiConfig.title |
| 21 | + - properties.connectorUiConfig.publisher |
| 22 | + - properties.connectorUiConfig.descriptionMarkdown |
| 23 | + - properties.connectorUiConfig.sampleQueries |
| 24 | + - properties.connectorUiConfig.graphQueries |
| 25 | + - properties.connectorUiConfig.dataTypes |
| 26 | + - properties.connectorUiConfig.connectivityCriteria |
| 27 | + - properties.connectorUiConfig.permissions |
| 28 | + - properties.connectorUiConfig.instructionSteps |
| 29 | + |
| 30 | + subcontexts: |
| 31 | + |
| 32 | + - name: sampleQueries |
| 33 | + when: "exists('properties.connectorUiConfig.sampleQueries')" |
| 34 | + array: |
| 35 | + path: "properties.connectorUiConfig.sampleQueries" |
| 36 | + require: |
| 37 | + - description |
| 38 | + - query |
| 39 | + |
| 40 | + - name: graphQueries |
| 41 | + when: "exists('properties.connectorUiConfig.graphQueries')" |
| 42 | + array: |
| 43 | + path: "properties.connectorUiConfig.graphQueries" |
| 44 | + require: |
| 45 | + - metricName |
| 46 | + - legend |
| 47 | + - baseQuery |
| 48 | + |
| 49 | + - name: permissions |
| 50 | + when : "exists('properties.connectorUiConfig.permissions.resourceProvider')" |
| 51 | + array: |
| 52 | + path: "properties.connectorUiConfig.permissions.resourceProvider" |
| 53 | + require: |
| 54 | + - provider |
| 55 | + - providerDisplayName |
| 56 | + - permissionsDisplayText |
| 57 | + - requiredPermissions |
| 58 | + - scope |
| 59 | + |
| 60 | + - name: dataTypes |
| 61 | + when: "exists('properties.connectorUiConfig.dataTypes')" |
| 62 | + array: |
| 63 | + path: "properties.connectorUiConfig.dataTypes" |
| 64 | + require: |
| 65 | + - name |
| 66 | + - lastDataReceivedQuery |
| 67 | + |
| 68 | + - name : connectivityCriteria |
| 69 | + when: "exists('properties.connectorUiConfig.connectivityCriteria')" |
| 70 | + array: |
| 71 | + path: "properties.connectorUiConfig.connectivityCriteria" |
| 72 | + |
| 73 | + - name: instructionSteps |
| 74 | + array: |
| 75 | + path: "properties.connectorUiConfig.instructionSteps" |
| 76 | + require: |
| 77 | + - instructions |
| 78 | + |
| 79 | + subarray: |
| 80 | + path: "instructions" ######################### leads form the relative path given in array |
| 81 | + require: |
| 82 | + - type |
| 83 | + |
| 84 | + subcontexts: |
| 85 | + |
| 86 | + - name: OAuthForm Instruction |
| 87 | + when: "get('type') == 'OAuthForm'" |
| 88 | + require: |
| 89 | + - parameters.disconnectButtonLabel |
| 90 | + - parameters.connectButtonLabel |
| 91 | + - parameters.clientSecretLabel |
| 92 | + - parameters.clientIdLabel |
| 93 | + |
| 94 | + - name: ConnectionToggleButton Instruction |
| 95 | + when: "get('type') == 'ConnectionToggleButton'" |
| 96 | + require: |
| 97 | + - parameters.connectLabel |
| 98 | + - parameters.name |
| 99 | + |
| 100 | + - name: CopyableLabel Instruction |
| 101 | + when: "get('type') == 'CopyableLabel'" |
| 102 | + require: |
| 103 | + - parameters.value |
| 104 | + - parameters.label |
| 105 | + |
| 106 | + - name: Textbox Instruction |
| 107 | + when: "get('type') == 'Textbox'" |
| 108 | + require: |
| 109 | + - parameters.label |
| 110 | + - parameters.placeholder |
| 111 | + - parameters.name |
| 112 | + |
| 113 | + |
| 114 | + |
| 115 | + |
| 116 | + |
| 117 | + |
| 118 | + |
| 119 | + |
| 120 | + |
| 121 | + |
| 122 | + |
| 123 | + |
| 124 | + |
| 125 | +# The rules.yml file defines validation rules for your JSON files. It tells your validator.py script: |
| 126 | + |
| 127 | +# When a rule should apply (when: clause) |
| 128 | +# What keys must be present (require: list) |
| 129 | +# What values must match exactly (equals: dictionary) |
| 130 | +# How to validate arrays of objects (array: and subarray: blocks) |
| 131 | +# Each rule is called a context, and contexts can be nested to validate substructures. |
| 132 | + |
| 133 | + |
| 134 | +#can have two require blocks can have two equal blocks also |
| 135 | + |
| 136 | +# Use exists('path') and get('path') in when: to control when a rule applies. |
| 137 | +# Use require: to enforce presence of keys. |
| 138 | +# Use equals: to enforce exact values. |
| 139 | +# Use array: and subarray: to validate lists of objects. |
| 140 | +# Nest subcontexts: to validate deeper structures. |
| 141 | + |
| 142 | + |
| 143 | +# subarray.path: This is the path to the nested array inside each item of the top-level array. Here: |
0 commit comments