We have a complex Visual Studio solution in .net that has many projects for units tests, integration tests and test harnesses. We want to run Fortify SCA at the time of automated deployment but exclude all the test projects from scanning. The command below doesn't exclude all the files within the sub-directories. The sub-directories / folders can be of many levels. It is very difficult to write exclude option for each and every levels of the folder structures. Any ideas?
Folder structure (to exclude):
C:\\src\Code\Test\IntegrationTests\IntregationTests1\..many files
C:\\src\Code\Test\IntegrationTests\IntregationTests2\..many files
C:\\src\Code\SomeProject1.Tests\..folders\..files
C:\\src\Code\SomeProject2.Tests\..folders\..files
C:\\src\Code\TestHarness\Project1\..folders\..files
C:\\src\Code\TestHarness\Project2\..folders\..files
Command to exclude the test projects
.\sourceanalyzer -b "APP" -exclude "C:\\src\Code\*Test*\*" devenv $SolutionPath /REBUILD
To solve the issue I wrote a PowerShell Script and passed the root path of the source code via an argument. Within the script, I listed the folders to be excluded in an array. The results of the SCA scanning was uploaded to the Fortify Dashboard.
param (
[string]$SourceRoot = "\"
)
$SolutionPath = "$($SourceRoot)\Code\Test.Web.sln"
$VersionID = "10101"
$UpToken = "98752711-c3e1-4d03-8dea-51f150638994"
$Excludes = @(
"$($SourceRoot)\code\unit.tests\**\*;",
"$($SourceRoot)\code\prototypes\**\*;",
"$($SourceRoot)\code\tools\**\*;"
)
.\sourceanalyzer -b "APP" -clean
.\sourceanalyzer -b "APP" -exclude "$($Excludes -join'')" msbuild /t:rebuild $SolutionPath
./scancentral.bat -url "http://10.10.10.10:8181/scancentral-ctrl" start -upload -versionid $VersionID -uptoken $UpToken -b "APP" -scan
.\sourceanalyzer -b "APP" -clean