RESTAPI: Generate Client Updates Baseline - Windows
Log In or Register to download the BES file, and more.

1 Votes

Versioning - This is the latest version.

1RESTAPI: Generate Client Updates Baseline - Windows6/30/2015 3:07:28 PM
2RESTAPI: Generate Client Updates Baseline - Windows6/30/2015 3:15:18 PM

Description

This task will generate a baseline on the target computer in the same site as this task is run from using the current console operator username and password and the REST API. This task uses secure parameters so the password is encrypted.

 

References:

http://superuser.com/questions/149329/what-is-the-curl-command-line-syntax-to-do-a-post-request

https://www.ibm.com/developerworks/community/wikis/home?lang=en#!/wiki/Tivoli%20Endpoint%20Manager/page/RESTAPI%20Task

https://github.com/bigfix/restapi-examples/tree/master/evaluate-relevance/cURL

http://bigfix.me/relevance/details/3002418

http://bigfix.me/relevance/details/3002370

http://bigfix.me/relevance/details/3002416

http://bigfix.me/relevance/details/3002416

 

Parameter Values:   (queried using JavaScript & console based session relevance)


Property Details

ID6116
StatusAlpha - Code that was just developed
TitleRESTAPI: Generate Client Updates Baseline - Windows
DomainBESC
CategoryConfiguration
Download Size0
Source IDjgstew
Source Release Date10/9/2014 12:00:00 AM
Added by on 6/30/2015 3:15:18 PM
Last Modified by on 6/30/2015 3:15:18 PM
Counters 6259 Views / 33 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

Windows Only (Relevance 2997197)
Used in 6452 fixlets and 32 analyses   * Results in a true/false
Show indented relevance
/* Windows Only */ windows of operating system
Used in 158 fixlets and 17 analyses   * Results in a true/false
Show indented relevance
/* Windows XP or Higher */ version of operating system >= "5.1"
BES Client is version 9+ (Relevance 2999387)
Used in 20 fixlets   * Results in a true/false
Show indented relevance
version of client >= "9.0" as version
Used in 2 fixlets   * Results in a true/false
Show indented relevance
not exists files whose(name of it starts with "RESTAPI_Baseline_" AND name of it as lowercase ends with ".log" AND (now - modification time of it < 7*day) ) of folder "__BESData\__Global\Logs" of parent folder of client

Actions

Action 1 (default)

Action Link Click here to deploy this action.
Script Type BigFix Action Script
// DEBUGGING: The following is for debugging
// appendfile {parameter "RootServerURL"}
// appendfile {parameter "currentSiteName"}
// appendfile {parameter "currentSiteType"}
// appendfile {parameter "currentConsoleUser"}
// move __appendfile __Download\parameters.txt
// parameter "secret" of action

// -- START:DOWNLOADS -------------------------

// - This is the commandline 7zip console which is use to unpack installers
// - https://www.virustotal.com/en/file/2a3afe19c180f8373fa02ff00254d5394fec0349f5804e0ad2f6067854ff28ac/analysis
prefetch 7za.zip sha1:9ce9ce89ebc070fea5d679936f21f9dde25faae0 size:384846 http://iweb.dl.sourceforge.net/project/sevenzip/7-Zip/9.20/7za920.zip

// - This unzip is a compiled verion of unzip v5.52 fom http://info-zip.org/
// - https://www.virustotal.com/en/file/8d9b5190aace52a1db1ac73a65ee9999c329157c8e88f61a772433323d6b7a4a/analysis
prefetch unzip.exe sha1:e1652b058195db3f5f754b7ab430652ae04a50b8 size:167936 http://software.bigfix.com/download/redist/unzip-5.52.exe

// Download CURL http://curl.haxx.se/download.html
// - Analysis of the CURL.exe inside: https://www.virustotal.com/en/file/7e4379dc72cc25e8d546b3f4b4305b93b6521aaae47c1ea2ee49e4cc4ce8b033/analysis/
prefetch curl.cab sha1:1d104ff75f52718709307ba03af0fcad17c1237a size:1435991 http://skanthak.homepage.t-online.de/download/curl-7.43.0.cab

// -- END:DOWNLOADS ---------------------------

// http://www-01.ibm.com/support/knowledgecenter/SS63NW_9.2.0/com.ibm.tivoli.tem.doc_9.2/Platform/Action/c_action_log.html
// https://forum.bigfix.com/t/newer-actionscript-commands/11677
action log command

// ADD TO UTILITY CACHE: unzip,7zip,curl
utility __Download\unzip.exe
utility __Download\7za.zip
utility __Download\curl.cab

// EXTRACT using unzip: the 7zip command line utility
waithidden __Download\unzip.exe -o "{pathname of file "7za.zip" of folder "__Download" of client folder of current site}" 7za.exe -d "{pathname of folder "__Download" of client folder of current site}"

// EXTRACT using 7zip: CURL
waithidden "{ (pathname of file "7za.exe" of folder "__Download" of client folder of current site) }" e -i!I386\Curl.EXE -y -o"{pathname of folder "__Download" of client folder of current site}" "{pathname of file "curl.cab" of folder "__Download" of client folder of current site}"


// VERIFY: Make sure the parameters are set
continue if { (parameter "currentSiteName" as trimmed string != "") AND (parameter "currentSiteType" as trimmed string != "") AND (parameter "RootServerURL" as trimmed string != "") }

// REST API
// https://www.ibm.com/developerworks/community/wikis/home?lang=en#!/wiki/Tivoli%20Endpoint%20Manager/page/RESTAPI%20Relevance
// http://meyerweb.com/eric/tools/dencoder/
// http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.1
// http://www.ietf.org/rfc/rfc1738.txt
// https://github.com/bigfix/restapi-examples/tree/master/evaluate-relevance/cURL
// curl --data-urlencode relevance="RELEVANCE" --user username:password https://server:port/api/query
// application/x-www-form-urlencoded
waithidden "{ (pathname of file "Curl.EXE" of folder "__Download" of client folder of current site) }" -k --data-urlencode relevance="concatenations %22%22 of (%22%22 & item 6 of it & %22%22 & item 8 of it & %22%22 & item 9 of it & %22%22) of (name of it, (it as string as lowercase) of (not success on run to completion of default action of it), url of site of it, (it as string) of id of it, content id of default action of it, script type of default action of it, (%22%22) of script of default action of it, (if (success on custom relevance of it) then %22CustomRelevance%22 else if (success on original relevance of it) then %22OriginalRelevance%22 else if (success on run to completion of it) then %22RunToCompletion%22 else %22%22) of default action of it, (if (not success on custom relevance of it) then %22%22 else (%22%22) of (custom success relevance of it)) of default action of it, (%22%22) of relevance of it) of fixlets whose(name of it does not contain %22(Superseded)%22 AND name of it as lowercase contains %22endpoint manager%22 AND name of it as lowercase contains %22client%22 AND globally visible flag of it) of bes sites whose(%22BES Support%22 = name of it)" -o "{pathname of folder "__Download" of client folder of current site}\BaselineComponents.xml" --user {parameter "currentConsoleUser"}:{parameter "secret"} https://{parameter "RootServerURL"}/api/query

delete __createfile
delete Baseline.bes

// CREATEFILE
createfile until END_OF_FILE
="1.0" encoding="UTF-8"?>
="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="BES.xsd">
    
        BigFix Client Updates <span class='actionscriptRelevance'>{ (year of it as string & month of it as two digits & day_of_month of it as two digits) of current date }</span>
        This baseline contains all of the current bigfix client update fixlets.
        true
        
        
        
        
        
        
        
            x-fixlet-modification-time
            {now as string}
        
        BESC
        
            
                {node value of xpath "/BESAPI/Query/Result/Answer/text()" of xml document of file "BaselineComponents.xml" of folder "__Download" of client folder of current site}
            
        
    

END_OF_FILE

move __createfile __Download\Baseline.bes

// Import Baseline.bes into custom site using API if there is at least one baseline component inside (use secure parameter for user password)
if{ (exists files "Baseline.bes" whose(exists contents whose(it contains "") of it) of folder "__Download" of client folder of current site) }
// IMPORT
    waithidden "{ (pathname of file "Curl.EXE" of folder "__Download" of client folder of current site) }" -k -X POST --data-binary @"{pathname of file "Baseline.bes" whose(exists contents whose(it contains "") of it) of folder "__Download" of client folder of current site}" --header "Content-Type:text/xml" -o "{(pathname of folder "__BESData\__Global\Logs" of parent folder of client)}\RESTAPI_Baseline_{parameter "currentSiteName"}.log" --user {parameter "currentConsoleUser"}:{parameter "secret"} https://{parameter "RootServerURL"}/api/import/{parameter "currentSiteType"}/{parameter "currentSiteName"}
endif

// VERIFY: Check if items were actually imported
// TODO: Need to add a check to see if the log file was created after the action started running (See adobe CC template for an example)
continue if{exists files whose((name of it = ("RESTAPI_Baseline_" & (parameter "currentSiteName") & ".log")) AND exists lines whose(it contains "") of it) of folder "__BESData\__Global\Logs" of parent folder of client}
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!
jgstew -
I haven't done so yet, but I am working on it in general. You can download the .bes file and edit it in a text editor to look at the relevance and actionscript to get an idea of what it does. You could even try copy and pasting it into a new task in the console.
eyalr -
Hello Did you upload it somewhere else so i can be test it ?
jgstew -
Very strange. There was an issue that BigFix.me was causing problems with the uploaded content by making some changes to it, but I thought that was fixed. I'll have to do some testing to see what the issue is. I may also upload these somewhere else so they can be downloaded unaltered since they are so complicated.
eyalr -
Maybe it can be an issue of some charterer that is not known to my environment. I tried it on few ones , it is doing the same on all.
eyalr -
No it is not , i also download your other RESTAPI files and have the same issue on all of them.
jgstew -
That is strange. That is a javascript file for a wizard, but this isn't a wizard, it is a task/fixlet. That does seem odd, though this does use some JavaScript. Did it ask you to trust the JavaScript?
eyalr -
I try to run this fixlet and I got this crash: "file:///C:/Program%20Files%20(x86)/BigFix%20Enterprise/BES%20Console/reference/wizards.js" "Windows Error 0x80020101: unknown error 0x80020101" Any idea how to solve it ? Thanks