Run test on modified schemas
This commit is contained in:
Родитель
ba7ebe3ced
Коммит
963d0d4f48
|
@ -44,7 +44,9 @@ jobs:
|
|||
exit 1
|
||||
fi
|
||||
- name: Run kqlFuncYaml2Arm script
|
||||
run: bash .script/kqlFuncYaml2Arm.sh
|
||||
run: |
|
||||
.script/kqlFuncYaml2Arm.ps1
|
||||
shell: pwsh
|
||||
- name: Commit changes
|
||||
run: |
|
||||
# Stage the files and commit
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
function getModifiedAsimSchemas() {
|
||||
$schemas = ("ASimDns", "ASimWebSession", "ASimNetworkSession", "ASimProcessEvent")
|
||||
$midifiedSchemas = @()
|
||||
foreach ($schema in $schemas) {
|
||||
$filesThatWereChanged= Invoke-Expression "git diff origin/master --name-only -- $($PSScriptRoot)/../Parsers/$($schema)/Parsers"
|
||||
if ($filesThatWereChanged) {
|
||||
Write-Host Files that were changed under Azure-Sentinel/Parsers/$schema/ARM:
|
||||
Write-Host - $filesThatWereChanged
|
||||
$midifiedSchemas += $schema
|
||||
}
|
||||
else {
|
||||
Write-Host "No files were changed under Azure-Sentinel/Parsers/$schema/"
|
||||
}
|
||||
}
|
||||
|
||||
return $midifiedSchemas
|
||||
}
|
||||
|
||||
getModifiedAsimSchemas
|
|
@ -0,0 +1,10 @@
|
|||
$failed=0
|
||||
# The KqlFuncYaml2Arm script generates deployable ARM templates from KQL function YAML files.
|
||||
# Currently, the script only runs on the Schemas listed below.
|
||||
$modifiedSchemas = & "$($PSScriptRoot)/getModifiedAsimSchemas.ps1"
|
||||
foreach($schema in $modifiedSchemas) {
|
||||
Remove-Item "$($PSScriptRoot)/../Parsers/$schema/ARM" -Recurse
|
||||
python ASIM/dev/ASimYaml2ARM/KqlFuncYaml2Arm.py -m asim -d Parsers/$schema/ARM Parsers/$schema/Parsers
|
||||
}
|
||||
|
||||
exit $failed
|
|
@ -1,21 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
failed=0
|
||||
|
||||
# The KqlFuncYaml2Arm script generates deployable ARM templates from KQL function YAML files.
|
||||
# Currently, the script only runs on the Schemas listed below.
|
||||
parsersSchemas=(ASimDns ASimNetworkSession ASimWebSession ASimProcessEvent)
|
||||
for schema in ${parsersSchemas[@]}
|
||||
do
|
||||
filesThatWereChanged=$(echo $(git diff origin/master --name-only -- Parsers/$schema/))
|
||||
if [ "$filesThatWereChanged" = "" ]; then
|
||||
echo No files were changed under Azure-Sentinel/Parsers/$schema/
|
||||
else
|
||||
echo Regenerate ARM templates under Azure-Sentinel/Parsers/$schema/ARM
|
||||
echo $filesThatWereChanged
|
||||
rm -rf Parsers//$schema/ARM
|
||||
python ASIM/dev/ASimYaml2ARM/KqlFuncYaml2Arm.py -m asim -d Parsers//$schema/ARM Parsers//$schema/Parsers
|
||||
fi
|
||||
done
|
||||
|
||||
exit $failed
|
|
@ -18,11 +18,12 @@ Class Parser {
|
|||
|
||||
function run {
|
||||
$subscription = Select-AzSubscription -SubscriptionId $global:subscriptionId
|
||||
$global:schemas | ForEach-Object { testSchema($_) }
|
||||
$modifiedSchemas = & "$($PSScriptRoot)/../../getModifiedASimSchemas.ps1"
|
||||
$modifiedSchemas | ForEach-Object { testSchema($_) }
|
||||
}
|
||||
|
||||
function testSchema([string] $schema) {
|
||||
$parsersAsObjects = & "$($PSScriptRoot)/convertYamlToObject.ps1" -Path "$($PSScriptRoot)/../../../Parsers/ASim$($schema)/Parsers"
|
||||
$parsersAsObjects = & "$($PSScriptRoot)/convertYamlToObject.ps1" -Path "$($PSScriptRoot)/../../../Parsers/$($schema)/Parsers"
|
||||
Write-Host "Testing $($schema) schema, $($parsersAsObjects.count) parsers were found"
|
||||
$parsersAsObjects | ForEach-Object {
|
||||
$functionName = "$($_.EquivalentBuiltInParser)V$($_.Parser.Version.Replace('.',''))"
|
||||
|
@ -30,7 +31,7 @@ function testSchema([string] $schema) {
|
|||
Write-Host "The parser '$($functionName)' is a main parser, ignoring it"
|
||||
}
|
||||
else {
|
||||
testParser([Parser]::new($functionName, $_.ParserQuery, $schema, $_.ParserParams))
|
||||
testParser([Parser]::new($functionName, $_.ParserQuery, $schema.replace("ASim", ""), $_.ParserParams))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче