Embedded Script Runner
Log In or Register to download the BES file, and more.

0 Votes

Description

Extracts, decodes and executes fixlet embedded scripts

NOTE: Fixlets with embedded scripts must reference a valid Applicability Fixlet's ID in the x-fixlet-scm-sentinel-idref MIMField. Embedded scripts will only be extracted and run from Fixlets whose applicability Fixlet evaluates to true.


Property Details

ID26949
StatusAlpha - Code that was just developed
TitleEmbedded Script Runner
DomainBESC
CategoryUtility
SourceInternal
Source Release Date9/15/2022 12:00:00 AM
Is TaskTrue
Added by on 9/15/2022 11:58:45 AM
Last Modified by on 9/15/2022 11:58:45 AM
Counters 89 Views / 0 Downloads
User Rating 1 star 2 star 3 star 4 star 5 star * Average over 0 ratings. ** Log In or Register to add your rating.

Relevance

Used in 91 fixlets and 94 analyses   * Results in a true/false
Show indented relevance
true

Actions

Action 1 (default)

Action Link Click here to deploy this action.
Script Type BigFix Action Script
parameter "root_dir"="{(pathname of parent folder of data folder of client) & "/SCM"}"
parameter "site_dir"="{(parameter "root_dir") & "/" & (name of current site)}"
parameter "scripts_dir"="{parameter "site_dir"}/scripts"
parameter "stdout_dir"="{parameter "site_dir"}/stdout"
parameter "stderr_dir"="{parameter "site_dir"}/stderr"
if { not exists folder (parameter "root_dir")}
folder create "{parameter "root_dir"}
endif
if { not exists folder (parameter "site_dir")}
folder create "{parameter "site_dir"}
endif
folder delete "{parameter "scripts_dir"}"
folder delete "{parameter "stdout_dir"}"
folder delete "{parameter "stderr_dir"}"
folder create "{parameter "scripts_dir"}"
folder create "{parameter "stdout_dir"}"
folder create "{parameter "stderr_dir"}"

//Consolidate all the parameters from x-fixlet-scm-parameters of all fixlets
createfile until __EOF
{concatenations "%0a" of (values of headers "x-fixlet-scm-parameters" of it) of fixlets of current site}
__EOF
delete delete "{parameter "scripts_dir"}/parameters.txt"
move __createfile "{parameter "scripts_dir"}/parameters.txt"

createfile until __EOF__
{concatenations "%0a" of (values of headers "x-fixlet-detect-script" of it) of fixlets whose (exists elements of (intersection of (set of (values of headers "x-fixlet-scm-sentinel-idref" of it) ; set of (values of headers "x-fixlet-scm-sentinel-id" of it) of (relevant fixlets of current site)))) of current site}
__EOF__
delete "{parameter "scripts_dir"}/detect_scripts"
move __createfile "{parameter "scripts_dir"}/detect_scripts"

if {(operating system as string) starts with "Win"}
createfile until __EOF
foreach($line in [System.IO.File]::ReadLines("{parameter "scripts_dir"}/detect_scripts")) {{
$scriptname = $line.split(":")[0]
[System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($line.split(":")[1])) > ("{parameter "scripts_dir"}/", $scriptname -join "")
try {{
& ("{parameter "scripts_dir"}/", $scriptname -join "") > ("{parameter "stdout_dir"}/", ($scriptname -replace ".ps1", ".out") -join "")
} catch {{
Write-Output $error > ("{parameter "stderr_dir"}/", ($scriptname -replace ".ps1", ".err") -join "")
}
}
__EOF
delete base64decode.ps1
move __createfile base64decode.ps1
waithidden powershell -F base64decode.ps1
elseif {(operating system as string) starts with "Linux"}
// WIP
endif
Success Criteria

This action will be considered successful when the applicability relevance evaluates to false.


Sharing

Social Media:
Share this page on Yammer

Comments

Log In or Register to leave comments!