Skip to content

Commit

Permalink
Fixes #25382: Typo in the windows technique generation template
Browse files Browse the repository at this point in the history
  • Loading branch information
Félix Dallidet committed Aug 29, 2024
1 parent 1980eab commit 47377a4
Show file tree
Hide file tree
Showing 15 changed files with 89 additions and 33 deletions.
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ pipeline {
agent {
dockerfile {
filename 'policies/Dockerfile'
additionalBuildArgs "--build-arg USER_ID=${env.JENKINS_UID} --build-arg RUDDER_VER=${env.RUDDER_VERSION}-nightly"
additionalBuildArgs "--build-arg USER_ID=${env.JENKINS_UID} --build-arg RUDDER_VER=${env.RUDDER_VERSION}-nightly --build-arg PSANALYZER_VER=1.20.0"
// mount cache
args '-v /srv/cache/cargo:/usr/local/cargo/registry -v /srv/cache/sccache:/home/jenkins/.cache/sccache -v /srv/cache/cargo-vet:/home/jenkins/.cache/cargo-vet'
}
Expand Down
2 changes: 2 additions & 0 deletions policies/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ COPY ci/user.sh .
RUN ./user.sh $USER_ID

ARG RUDDER_VER=latest
ARG PSANALYZER_VERSION=1.20.0

COPY ci/rust.sh .
RUN ./rust.sh
Expand All @@ -21,4 +22,5 @@ apt-get install ./powershell_7.4.0-1.deb_amd64.deb
apt-get update && apt-get install -y rsync msitools
# ignore postinst failures
curl https://repository.rudder.io/tools/rudder-setup | sed 's/rudder agent \(.*\)/rudder agent \1 \| true/g' | bash -s setup-agent $RUDDER_VER
pwsh -Command Install-Module -Name PSScriptAnalyzer -RequiredVersion $PSANALYZER_VERSION -Scope AllUsers -Confirm:\$false -Force
EOF
5 changes: 4 additions & 1 deletion policies/rudderc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ test: libs
# Parse lib
cargo run --quiet --bin rudderc -- --quiet lib -f json --stdout -l target/repos/ncf/tree/30_generic_methods/ -l target/repos/dsc/plugin/src/ncf/30_generic_methods/ >/dev/null

test-powershell:
pwsh -command 'Get-ChildItem -Recurse -Path tests/cases/general -Include "*.ps1" | ? { $$_.FullName -inotmatch "target" } | %{ echo $$_.Directory.FullName; Invoke-ScriptAnalyzer -Settings ./PSScriptAnalyzerSettings.psd1 -Path $$_.Directory.FullName -EnableExit -ReportSummary }'

static: libs version
cargo auditable build --release --locked --features embedded-lib

Expand All @@ -44,6 +47,6 @@ agent-windows: libs
# Simulate a real agent to get correct reporting
echo "1d58a791-7278-4a2c-a10d-048c7b4be2a6" > target/agent-windows/Rudder/etc/uuid.hive

check: lint test test-docs
check: lint test test-docs test-powershell

.PHONY: docs libs clean
36 changes: 36 additions & 0 deletions policies/rudderc/PSScriptAnalyzerSettings.psd1
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
@{
IncludeDefaultRules = $True
Rules = @{
PSPlaceOpenBrace = @{
Enable = $true
OnSameLine = $true
NewLineAfter = $true
IgnoreOneLineBlock = $true
}

PSPlaceCloseBrace = @{
Enable = $true
NoEmptyLineBefore = $false
IgnoreOneLineBlock = $true
NewLineAfter = $false
}
}

ExcludeRules = @(
"PSUseDeclaredVarsMoreThanAssignments",
"PSAvoidTrailingWhitespace",
"PSUseConsistentIndentation",
"PSUseConsistentWhitespace",
"AvoidUninitializedVariableInModule",
"PSAvoidUsingWriteHost",
"PSUseApprovedVerbs",
"PSAvoidDefaultValueSwitchParameter",
"PSUseOutputTypeCorrectly",
"PSUseShouldProcessForStateChangingFunctions",
"PSAvoidUsingInvokeExpression",
"PSAvoidUsingPlainTextForPassword",
"PSAvoidUsingConvertToSecureStringWithPlainText",
"PSUseSingularNouns",
"PSUseToExportFieldsInManifest"
)
}
15 changes: 15 additions & 0 deletions policies/rudderc/generate-all-test-cases.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
set -e

TEST_DIR="$(git rev-parse --show-toplevel)/policies/rudderc/tests/cases/general"
RUDDERC="$(git rev-parse --show-toplevel)/target/debug/rudderc"
LIBRARY="$(git rev-parse --show-toplevel)/policies/rudderc/tests/lib"

find "${TEST_DIR}" -name "*.ps1" -not -path "*/target/*" -print0 | while read -d $'\0' TECHNIQUE
do
echo "Generating expected image file for the test technique $TECHNIQUE"
WORK_DIR=$(mktemp -d)
TECHNIQUE_DIR=$(dirname $TECHNIQUE)
cp -r $TECHNIQUE_DIR/* $WORK_DIR/
$RUDDERC --directory $WORK_DIR build --library $LIBRARY --output $TECHNIQUE_DIR
done
2 changes: 1 addition & 1 deletion policies/rudderc/templates/technique.ps1.askama
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function {{ id|technique_name }} {
)
Compute-Method-Call @fallBackReportParams -PolicyMode {{ m.policy_mode_override|policy_mode_fmt }} -ReportId $reportId -DisableReporting:${{ m.disable_reporting }} -MethodCall $failedCall
} catch {
$failedCall = [Rudder.MethodResult]::Error()
$failedCall = [Rudder.MethodResult]::Error(
[Rudder.MethodStatus]::Error,
([String]::Format(
'The method call was skipped as an unexpected error was thrown "{0}"',
Expand Down
4 changes: 2 additions & 2 deletions policies/rudderc/tests/cases/general/escaping/technique.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ if(Get-Service "Zabbix agent") { write-output "exists" }
)
Compute-Method-Call @fallBackReportParams -PolicyMode $policyMode -ReportId $reportId -DisableReporting:$false -MethodCall $failedCall
} catch {
$failedCall = [Rudder.MethodResult]::Error()
$failedCall = [Rudder.MethodResult]::Error(
[Rudder.MethodStatus]::Error,
([String]::Format(
'The method call was skipped as an unexpected error was thrown "{0}"',
Expand Down Expand Up @@ -184,7 +184,7 @@ if(Get-Service "Zabbix agent") { write-output "exists" }
)
Compute-Method-Call @fallBackReportParams -PolicyMode $policyMode -ReportId $reportId -DisableReporting:$false -MethodCall $failedCall
} catch {
$failedCall = [Rudder.MethodResult]::Error()
$failedCall = [Rudder.MethodResult]::Error(
[Rudder.MethodStatus]::Error,
([String]::Format(
'The method call was skipped as an unexpected error was thrown "{0}"',
Expand Down
2 changes: 1 addition & 1 deletion policies/rudderc/tests/cases/general/form/technique.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ htop
)
Compute-Method-Call @fallBackReportParams -PolicyMode $policyMode -ReportId $reportId -DisableReporting:$false -MethodCall $failedCall
} catch {
$failedCall = [Rudder.MethodResult]::Error()
$failedCall = [Rudder.MethodResult]::Error(
[Rudder.MethodStatus]::Error,
([String]::Format(
'The method call was skipped as an unexpected error was thrown "{0}"',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
)
Compute-Method-Call @fallBackReportParams -PolicyMode $policyMode -ReportId $reportId -DisableReporting:$false -MethodCall $failedCall
} catch {
$failedCall = [Rudder.MethodResult]::Error()
$failedCall = [Rudder.MethodResult]::Error(
[Rudder.MethodStatus]::Error,
([String]::Format(
'The method call was skipped as an unexpected error was thrown "{0}"',
Expand Down
2 changes: 1 addition & 1 deletion policies/rudderc/tests/cases/general/min/technique.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ htop
)
Compute-Method-Call @fallBackReportParams -PolicyMode $policyMode -ReportId $reportId -DisableReporting:$false -MethodCall $failedCall
} catch {
$failedCall = [Rudder.MethodResult]::Error()
$failedCall = [Rudder.MethodResult]::Error(
[Rudder.MethodStatus]::Error,
([String]::Format(
'The method call was skipped as an unexpected error was thrown "{0}"',
Expand Down
4 changes: 2 additions & 2 deletions policies/rudderc/tests/cases/general/ntp/technique.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ htop
)
Compute-Method-Call @fallBackReportParams -PolicyMode $policyMode -ReportId $reportId -DisableReporting:$false -MethodCall $failedCall
} catch {
$failedCall = [Rudder.MethodResult]::Error()
$failedCall = [Rudder.MethodResult]::Error(
[Rudder.MethodStatus]::Error,
([String]::Format(
'The method call was skipped as an unexpected error was thrown "{0}"',
Expand Down Expand Up @@ -125,7 +125,7 @@ vars.node.inventory.os.fullName
)
Compute-Method-Call @fallBackReportParams -PolicyMode $policyMode -ReportId $reportId -DisableReporting:$false -MethodCall $failedCall
} catch {
$failedCall = [Rudder.MethodResult]::Error()
$failedCall = [Rudder.MethodResult]::Error(
[Rudder.MethodStatus]::Error,
([String]::Format(
'The method call was skipped as an unexpected error was thrown "{0}"',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ vars.param_in_condition.file
)
Compute-Method-Call @fallBackReportParams -PolicyMode $policyMode -ReportId $reportId -DisableReporting:$false -MethodCall $failedCall
} catch {
$failedCall = [Rudder.MethodResult]::Error()
$failedCall = [Rudder.MethodResult]::Error(
[Rudder.MethodStatus]::Error,
([String]::Format(
'The method call was skipped as an unexpected error was thrown "{0}"',
Expand Down Expand Up @@ -105,7 +105,7 @@ echo "May be executed or not"
)
Compute-Method-Call @fallBackReportParams -PolicyMode $policyMode -ReportId $reportId -DisableReporting:$false -MethodCall $failedCall
} catch {
$failedCall = [Rudder.MethodResult]::Error()
$failedCall = [Rudder.MethodResult]::Error(
[Rudder.MethodStatus]::Error,
([String]::Format(
'The method call was skipped as an unexpected error was thrown "{0}"',
Expand Down
24 changes: 12 additions & 12 deletions policies/rudderc/tests/cases/general/policy_mode/technique.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ foobar
)
Compute-Method-Call @fallBackReportParams -PolicyMode ([Rudder.PolicyMode]::Audit) -ReportId $reportId -DisableReporting:$false -MethodCall $failedCall
} catch {
$failedCall = [Rudder.MethodResult]::Error()
$failedCall = [Rudder.MethodResult]::Error(
[Rudder.MethodStatus]::Error,
([String]::Format(
'The method call was skipped as an unexpected error was thrown "{0}"',
Expand Down Expand Up @@ -109,7 +109,7 @@ foobar
)
Compute-Method-Call @fallBackReportParams -PolicyMode $policyMode -ReportId $reportId -DisableReporting:$false -MethodCall $failedCall
} catch {
$failedCall = [Rudder.MethodResult]::Error()
$failedCall = [Rudder.MethodResult]::Error(
[Rudder.MethodStatus]::Error,
([String]::Format(
'The method call was skipped as an unexpected error was thrown "{0}"',
Expand Down Expand Up @@ -158,7 +158,7 @@ foobar
)
Compute-Method-Call @fallBackReportParams -PolicyMode ([Rudder.PolicyMode]::Enforce) -ReportId $reportId -DisableReporting:$false -MethodCall $failedCall
} catch {
$failedCall = [Rudder.MethodResult]::Error()
$failedCall = [Rudder.MethodResult]::Error(
[Rudder.MethodStatus]::Error,
([String]::Format(
'The method call was skipped as an unexpected error was thrown "{0}"',
Expand Down Expand Up @@ -207,7 +207,7 @@ foobar
)
Compute-Method-Call @fallBackReportParams -PolicyMode $policyMode -ReportId $reportId -DisableReporting:$false -MethodCall $failedCall
} catch {
$failedCall = [Rudder.MethodResult]::Error()
$failedCall = [Rudder.MethodResult]::Error(
[Rudder.MethodStatus]::Error,
([String]::Format(
'The method call was skipped as an unexpected error was thrown "{0}"',
Expand Down Expand Up @@ -256,7 +256,7 @@ foobar
)
Compute-Method-Call @fallBackReportParams -PolicyMode ([Rudder.PolicyMode]::Audit) -ReportId $reportId -DisableReporting:$false -MethodCall $failedCall
} catch {
$failedCall = [Rudder.MethodResult]::Error()
$failedCall = [Rudder.MethodResult]::Error(
[Rudder.MethodStatus]::Error,
([String]::Format(
'The method call was skipped as an unexpected error was thrown "{0}"',
Expand Down Expand Up @@ -305,7 +305,7 @@ foobar
)
Compute-Method-Call @fallBackReportParams -PolicyMode ([Rudder.PolicyMode]::Enforce) -ReportId $reportId -DisableReporting:$false -MethodCall $failedCall
} catch {
$failedCall = [Rudder.MethodResult]::Error()
$failedCall = [Rudder.MethodResult]::Error(
[Rudder.MethodStatus]::Error,
([String]::Format(
'The method call was skipped as an unexpected error was thrown "{0}"',
Expand Down Expand Up @@ -354,7 +354,7 @@ foobar
)
Compute-Method-Call @fallBackReportParams -PolicyMode ([Rudder.PolicyMode]::Audit) -ReportId $reportId -DisableReporting:$false -MethodCall $failedCall
} catch {
$failedCall = [Rudder.MethodResult]::Error()
$failedCall = [Rudder.MethodResult]::Error(
[Rudder.MethodStatus]::Error,
([String]::Format(
'The method call was skipped as an unexpected error was thrown "{0}"',
Expand Down Expand Up @@ -403,7 +403,7 @@ foobar
)
Compute-Method-Call @fallBackReportParams -PolicyMode ([Rudder.PolicyMode]::Audit) -ReportId $reportId -DisableReporting:$false -MethodCall $failedCall
} catch {
$failedCall = [Rudder.MethodResult]::Error()
$failedCall = [Rudder.MethodResult]::Error(
[Rudder.MethodStatus]::Error,
([String]::Format(
'The method call was skipped as an unexpected error was thrown "{0}"',
Expand Down Expand Up @@ -452,7 +452,7 @@ foobar
)
Compute-Method-Call @fallBackReportParams -PolicyMode ([Rudder.PolicyMode]::Enforce) -ReportId $reportId -DisableReporting:$false -MethodCall $failedCall
} catch {
$failedCall = [Rudder.MethodResult]::Error()
$failedCall = [Rudder.MethodResult]::Error(
[Rudder.MethodStatus]::Error,
([String]::Format(
'The method call was skipped as an unexpected error was thrown "{0}"',
Expand Down Expand Up @@ -501,7 +501,7 @@ foobar
)
Compute-Method-Call @fallBackReportParams -PolicyMode ([Rudder.PolicyMode]::Enforce) -ReportId $reportId -DisableReporting:$false -MethodCall $failedCall
} catch {
$failedCall = [Rudder.MethodResult]::Error()
$failedCall = [Rudder.MethodResult]::Error(
[Rudder.MethodStatus]::Error,
([String]::Format(
'The method call was skipped as an unexpected error was thrown "{0}"',
Expand Down Expand Up @@ -550,7 +550,7 @@ foobar
)
Compute-Method-Call @fallBackReportParams -PolicyMode ([Rudder.PolicyMode]::Audit) -ReportId $reportId -DisableReporting:$false -MethodCall $failedCall
} catch {
$failedCall = [Rudder.MethodResult]::Error()
$failedCall = [Rudder.MethodResult]::Error(
[Rudder.MethodStatus]::Error,
([String]::Format(
'The method call was skipped as an unexpected error was thrown "{0}"',
Expand Down Expand Up @@ -599,7 +599,7 @@ foobar
)
Compute-Method-Call @fallBackReportParams -PolicyMode ([Rudder.PolicyMode]::Enforce) -ReportId $reportId -DisableReporting:$false -MethodCall $failedCall
} catch {
$failedCall = [Rudder.MethodResult]::Error()
$failedCall = [Rudder.MethodResult]::Error(
[Rudder.MethodStatus]::Error,
([String]::Format(
'The method call was skipped as an unexpected error was thrown "{0}"',
Expand Down
16 changes: 8 additions & 8 deletions policies/rudderc/tests/cases/general/reporting/technique.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ htop
)
Compute-Method-Call @fallBackReportParams -PolicyMode $policyMode -ReportId $reportId -DisableReporting:$false -MethodCall $failedCall
} catch {
$failedCall = [Rudder.MethodResult]::Error()
$failedCall = [Rudder.MethodResult]::Error(
[Rudder.MethodStatus]::Error,
([String]::Format(
'The method call was skipped as an unexpected error was thrown "{0}"',
Expand Down Expand Up @@ -111,7 +111,7 @@ htop
)
Compute-Method-Call @fallBackReportParams -PolicyMode $policyMode -ReportId $reportId -DisableReporting:$false -MethodCall $failedCall
} catch {
$failedCall = [Rudder.MethodResult]::Error()
$failedCall = [Rudder.MethodResult]::Error(
[Rudder.MethodStatus]::Error,
([String]::Format(
'The method call was skipped as an unexpected error was thrown "{0}"',
Expand Down Expand Up @@ -159,7 +159,7 @@ ntp
)
Compute-Method-Call @fallBackReportParams -PolicyMode $policyMode -ReportId $reportId -DisableReporting:$false -MethodCall $failedCall
} catch {
$failedCall = [Rudder.MethodResult]::Error()
$failedCall = [Rudder.MethodResult]::Error(
[Rudder.MethodStatus]::Error,
([String]::Format(
'The method call was skipped as an unexpected error was thrown "{0}"',
Expand Down Expand Up @@ -207,7 +207,7 @@ ntp
)
Compute-Method-Call @fallBackReportParams -PolicyMode $policyMode -ReportId $reportId -DisableReporting:$false -MethodCall $failedCall
} catch {
$failedCall = [Rudder.MethodResult]::Error()
$failedCall = [Rudder.MethodResult]::Error(
[Rudder.MethodStatus]::Error,
([String]::Format(
'The method call was skipped as an unexpected error was thrown "{0}"',
Expand Down Expand Up @@ -255,7 +255,7 @@ ntp
)
Compute-Method-Call @fallBackReportParams -PolicyMode $policyMode -ReportId $reportId -DisableReporting:$false -MethodCall $failedCall
} catch {
$failedCall = [Rudder.MethodResult]::Error()
$failedCall = [Rudder.MethodResult]::Error(
[Rudder.MethodStatus]::Error,
([String]::Format(
'The method call was skipped as an unexpected error was thrown "{0}"',
Expand Down Expand Up @@ -303,7 +303,7 @@ ntp
)
Compute-Method-Call @fallBackReportParams -PolicyMode $policyMode -ReportId $reportId -DisableReporting:$false -MethodCall $failedCall
} catch {
$failedCall = [Rudder.MethodResult]::Error()
$failedCall = [Rudder.MethodResult]::Error(
[Rudder.MethodStatus]::Error,
([String]::Format(
'The method call was skipped as an unexpected error was thrown "{0}"',
Expand Down Expand Up @@ -351,7 +351,7 @@ ntp
)
Compute-Method-Call @fallBackReportParams -PolicyMode $policyMode -ReportId $reportId -DisableReporting:$false -MethodCall $failedCall
} catch {
$failedCall = [Rudder.MethodResult]::Error()
$failedCall = [Rudder.MethodResult]::Error(
[Rudder.MethodStatus]::Error,
([String]::Format(
'The method call was skipped as an unexpected error was thrown "{0}"',
Expand Down Expand Up @@ -399,7 +399,7 @@ ntp
)
Compute-Method-Call @fallBackReportParams -PolicyMode $policyMode -ReportId $reportId -DisableReporting:$true -MethodCall $failedCall
} catch {
$failedCall = [Rudder.MethodResult]::Error()
$failedCall = [Rudder.MethodResult]::Error(
[Rudder.MethodStatus]::Error,
([String]::Format(
'The method call was skipped as an unexpected error was thrown "{0}"',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ vars.node.properties.name.key
)
Compute-Method-Call @fallBackReportParams -PolicyMode $policyMode -ReportId $reportId -DisableReporting:$false -MethodCall $failedCall
} catch {
$failedCall = [Rudder.MethodResult]::Error()
$failedCall = [Rudder.MethodResult]::Error(
[Rudder.MethodStatus]::Error,
([String]::Format(
'The method call was skipped as an unexpected error was thrown "{0}"',
Expand Down

0 comments on commit 47377a4

Please sign in to comment.