By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,950 Members | 1,005 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,950 IT Pros & Developers. It's quick & easy.

PowerShell script to run Fortify Scan gives errors

100+
P: 109
Hello Experts! I am trying to build a script that performs automated scanning using HP Fortify from the command line. I thought I was passing my parameters correctly but something is not quite right. The command prompt script that does this is:

Expand|Select|Wrap|Line Numbers
  1. ECHO prime clean
  2. sourceanalyzer -b prime -clean
  3.  
  4. ECHO prime translate
  5. sourceanalyzer -b prime %1 -debug -verbose -logfile prime.log -Dcom.fortify.sca.Phase0HigherOrder.Languages=python,ruby,javascript 
  6.  
  7. ECHO prime show files
  8. sourceanalyzer -b prime -show-files> files_prime
  9.  
  10. ECHO prime scan
  11. sourceanalyzer -b prime -logfile prime.scan -scan -f prime.fpr 
  12.  
  13. ECHO prime upload to SSC
  14. fortifyclient -url http://Fortify/ssc -authtoken xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx uploadFPR -file prime.fpr -project prime-upload -version version-1.0
  15.  
  16.  
The PowerShell commands that should match up are:

Expand|Select|Wrap|Line Numbers
  1. $Appname = "Fortify Command Line Scanner"
  2. $src = "src/**/*.js" 
  3.  
  4. Write-Host $Appname
  5. ForEach ($Item in $args){
  6.  
  7.    $ThePath = $Item
  8.    $ChildPath = Split-Path $ThePath -Leaf
  9.    $ParPath = Split-Path $ThePath -Parent
  10.  
  11.    Write-Host "Processing Application located at $ThePath"
  12.  
  13.    Write-Host "Cleaning"
  14.    sourceanalyzer -b $ChildPath -clean
  15.  
  16.    Write-Host "Translation"
  17.    sourceanalyzer -b $ChildPath $ThePath$src -debug -verbose -logfile + $ChildPath.log -Dcom.fortify.sca.Phase0HigherOrder.Languages=python,ruby,javascript
  18.  
  19.    Write-Host "Show Files"
  20.    sourceanalyzer -b $ChildPath -show-files> + files_$ChildPath
  21.  
  22.    Write-Host "Scanning"
  23.    sourceanalyzer -b $ChildPath -logfile + $ChildPath.scan -scan -f + $ChildPath.fpr
  24.  
  25.    Write-Host "Uploading to SSC"
  26.    fortifyclient -url http://Fortify/ssc -authtoken xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx uploadFPR -file $ChildPath.fpr -project $ChildPath -upload -version version-1.0
  27. }
  28.  
When I run the PowerShell command, I get errors. These errors are as follows:

Expand|Select|Wrap|Line Numbers
  1. Translation
  2. sourceanalyzer : [error]: No parameter specified for argument -logfile
  3. At C:\powershell\FortifyCLS.ps1:31 char:4
  4. + sourceanalyzer -b $ChildPath $ThePath$src -debug -verbose -logfile $ChildPath ...
  5. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  6.     + CategoryInfo          : NotSpecified: ([error]: No par...gument -logfile:String) [], RemoteException
  7.     + FullyQualifiedErrorId : NativeCommandError
  8.  
  9. HP Fortify Static Code Analyzer 6.40.0089 (using JVM 1.8.0_45)
  10. HP Fortify Static Code Analyzer 6.40.0089
  11. Copyright (c) 2003-2015 Hewlett Packard Enterprise Development LP
  12.  
  13. For command-line help, type 'sourceanalyzer -h'
  14.  
  15. sourceanalyzer -b sampleOutput C:\Program Files\HP_Fortify\HP_Fortify_SCA_and_Apps_4.40\Samples\basic\sampleOutputsrc/**/*.js -debug -verbose -logfile sampleOutput.log -D
  16. com.fortify.sca.Phase0HigherOrder.Languages=python,ruby,javascript
  17. Show Files
  18. sourceanalyzer : [error]: Unrecognized or invalid command line argument '-show-files>'
  19. At C:\powershell\FortifyCLS.ps1:35 char:4
  20. +    sourceanalyzer -b $ChildPath -show-files> files_$ChildPath
  21. +    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  22.     + CategoryInfo          : NotSpecified: ([error]: Unreco... '-show-files>':String) [], RemoteException
  23.     + FullyQualifiedErrorId : NativeCommandError
  24.  
  25. HP Fortify Static Code Analyzer 6.40.0089
  26. Copyright (c) 2003-2015 Hewlett Packard Enterprise Development LP
  27.  
  28. For command-line help, type 'sourceanalyzer -h'
  29.  
  30. sourceanalyzer -b sampleOutput -show-files> files_sampleOutput
  31. Scanning
  32. sourceanalyzer : [error]: No parameter specified for argument -logfile
  33. At C:\powershell\prime.ps1:39 char:4
  34. +    sourceanalyzer -b $ChildPath -logfile $ChildPath.scan -scan -f $ChildPath.fpr
  35. +    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  36.     + CategoryInfo          : NotSpecified: ([error]: No par...gument -logfile:String) [], RemoteException
  37.     + FullyQualifiedErrorId : NativeCommandError
  38.  
When I output the stuff to the screen using Write-Host, the commands look correct and match what works. So what the heck am I doing wrong? I'm including a copy of the script to help with debugging. Thank you!
Attached Files
File Type: txt FortifyCLS.txt (2.2 KB, 313 views)
May 6 '16 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.