-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathFortifySimpleTests.bat
More file actions
154 lines (144 loc) · 6.29 KB
/
Copy pathFortifySimpleTests.bat
File metadata and controls
154 lines (144 loc) · 6.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
@echo off
REM ###########################################################################
REM Script generated by Fortify SCA Scan Wizard (c) 2011-2018 Micro Focus or one of its affiliates
REM Created on 2018/08/26 12:14:07
REM ###########################################################################
REM Generated for the following languages:
REM Java
REM XML
REM ###########################################################################
REM DEBUG - if set to true, runs SCA in debug mode
REM SOURCEANALYZER - the name of the SCA executable
REM FPR - the name of analysis result file
REM BUILDID - the SCA build id
REM ARGFILE - the name of the argument file that's extracted and passed to SCA
REM BYTECODE_ARGFILE - the name of the argument file for Java Bytecode translation that's extracted and passed to SCA
REM MEMORY - the memory settings for SCA
REM LAUNCHERSWITCHES - the launcher settings that are used to invoke SCA
REM OLDFILENUMBER - this defines the file which contains the number of files within the project, it is automatically generated
REM FILENOMAXDIFF - this is the percentage of difference between the number of files which will trigger a warning by the script
REM ###########################################################################
git reset --hard simpleTest/master
git pull
set DEBUG=false
set SOURCEANALYZER=sourceanalyzer
set FPR="FortifySimpleTests.fpr"
set BUILDID="SimpleTests"
set ARGFILE="FortifySimpleTests.bat.args"
set BYTECODE_ARGFILE="FortifySimpleTests.bat.bytecode.args"
set MEMORY=-Xmx14566M -Xms400M -Xss24M
set LAUNCHERSWITCHES=""
set OLDFILENUMBER=FortifySimpleTests.bat.fileno
set FILENOMAXDIFF=10
set ENABLE_BYTECODE=false
set PROJECTROOT0="C:\git\SimpleTests"
IF NOT EXIST %PROJECTROOT0% (
ECHO ERROR: This script is being run on a different machine than it was
ECHO generated on or the targeted project has been moved. This script is
ECHO configured to locate files at
ECHO %PROJECTROOT0%
ECHO Please modify the %%PROJECTROOT0%% variable found
ECHO at the top of this script to point to the corresponding directory
ECHO located on this machine.
GOTO :FINISHED
)
IF %DEBUG%==true set LAUNCHERSWITCHES=-debug %LAUNCHERSWITCHES%
echo Extracting Arguments File
echo. >%ARGFILE%
echo. >%BYTECODE_ARGFILE%
SETLOCAL ENABLEDELAYEDEXPANSION
IF EXIST %0 (
set SCAScriptFile=%0
) ELSE (
set SCAScriptFile=%0.bat
)
set PROJECTROOT0=%PROJECTROOT0:)=^)%
FOR /f "delims=" %%a IN ('findstr /B /C:"REM ARGS" %SCAScriptFile%' ) DO (
set argVal=%%a
set argVal=!argVal:PROJECTROOT0_MARKER=%PROJECTROOT0:~1,-1%!
echo !argVal:~9! >> %ARGFILE%
)
set PROJECTROOT0=%PROJECTROOT0:)=^)%
FOR /f "delims=" %%a IN ('findstr /B /C:"REM BYTECODE_ARGS" %SCAScriptFile%' ) DO (
set ENABLE_BYTECODE=true
set argVal=%%a
set argVal=!argVal:PROJECTROOT0_MARKER=%PROJECTROOT0:~1,-1%!
echo !argVal:~18! >> %BYTECODE_ARGFILE%
)
ENDLOCAL && set ENABLE_BYTECODE=%ENABLE_BYTECODE%
REM ###########################################################################
echo Cleaning previous scan artifacts
%SOURCEANALYZER% %MEMORY% %LAUNCHERSWITCHES% -b %BUILDID% -clean
IF %ERRORLEVEL%==1 (
echo Sourceanalyzer failed, exiting
GOTO :FINISHED
)
REM ###########################################################################
echo Translating files
%SOURCEANALYZER% %MEMORY% %LAUNCHERSWITCHES% -b %BUILDID% @%ARGFILE%
IF %ERRORLEVEL%==1 (
echo Sourceanalyzer failed, exiting
GOTO :FINISHED
)
REM ###########################################################################
IF %ENABLE_BYTECODE%==true (
echo Translating Java bytecode files
%SOURCEANALYZER% %MEMORY% %LAUNCHERSWITCHES% -b %BUILDID% @%BYTECODE_ARGFILE%
IF %ERRORLEVEL%==1 (
echo Sourceanalyzer failed, exiting
GOTO :FINISHED
)
)
REM ###########################################################################
echo Testing Difference between Translations
SETLOCAL
FOR /F "delims=" %%A in ('%SOURCEANALYZER% -b %BUILDID% -show-files ^| findstr /R /N "^" ^| find /C ":" ') DO SET FILENUMBER=%%A
IF NOT EXIST %OLDFILENUMBER% (
ECHO It appears to be the first time running this script, setting %OLDFILENUMBER% to %FILENUMBER%
ECHO %FILENUMBER% > %OLDFILENUMBER%
GOTO TESTENDED
)
FOR /F "delims=" %%i IN (%OLDFILENUMBER%) DO SET OLDFILENO=%%i
set /a DIFF=%OLDFILENO% * %FILENOMAXDIFF%
set /a DIFF /= 100
set /a MAX=%OLDFILENO% + %DIFF%
set /a MIN=%OLDFILENO% - %DIFF%
IF %FILENUMBER% LSS %MIN% set SHOWWARNING=true
IF %FILENUMBER% GTR %MAX% set SHOWWARNING=true
IF DEFINED SHOWWARNING (
ECHO WARNING: The number of files has changed by over %FILENOMAXDIFF%%%, it is recommended
ECHO that this script is regenerated with the ScanWizard
)
:TESTENDED
ENDLOCAL
REM ###########################################################################
echo Starting scan
%SOURCEANALYZER% %MEMORY% %LAUNCHERSWITCHES% -b %BUILDID% -scan -f %FPR%
IF %ERRORLEVEL%==1 (
echo Sourceanalyzer failed, exiting
GOTO :FINISHED
)
REM ###########################################################################
echo Finished
:FINISHED
call copy.bat
REM ARGS "-cp"
REM ARGS "PROJECTROOT0_MARKER\target\test-classes"
REM ARGS "-source"
REM ARGS "1.8"
REM ARGS "-exclude" "PROJECTROOT0_MARKER\target\test-classes\com\simple\Simple3Test.class"
REM ARGS "-exclude" "PROJECTROOT0_MARKER\target\test-classes\com\simple\SimpleTest.class"
REM ARGS "-exclude" "PROJECTROOT0_MARKER\target\test-classes\com\simple2\Simple2Test.class"
REM ARGS "-exclude" "PROJECTROOT0_MARKER\.idea\compiler.xml"
REM ARGS "-exclude" "PROJECTROOT0_MARKER\.idea\copyright\profiles_settings.xml"
REM ARGS "-exclude" "PROJECTROOT0_MARKER\.idea\libraries\Maven__junit_junit_4_12.xml"
REM ARGS "-exclude" "PROJECTROOT0_MARKER\.idea\libraries\Maven__org_hamcrest_hamcrest_core_1_3.xml"
REM ARGS "-exclude" "PROJECTROOT0_MARKER\.idea\misc.xml"
REM ARGS "-exclude" "PROJECTROOT0_MARKER\.idea\modules.xml"
REM ARGS "-exclude" "PROJECTROOT0_MARKER\.idea\uiDesigner.xml"
REM ARGS "-exclude" "PROJECTROOT0_MARKER\.idea\vcs.xml"
REM ARGS "-exclude" "PROJECTROOT0_MARKER\.idea\workspace.xml"
REM ARGS "-exclude" "PROJECTROOT0_MARKER\target\surefire-reports\TEST-com.simple.Simple3Test.xml"
REM ARGS "-exclude" "PROJECTROOT0_MARKER\target\surefire-reports\TEST-com.simple.SimpleTest.xml"
REM ARGS "-exclude" "PROJECTROOT0_MARKER\target\surefire-reports\TEST-com.simple2.Simple2Test.xml"
REM ARGS "PROJECTROOT0_MARKER"