@@ -48,24 +48,24 @@ public CxWrapper(@NonNull CxConfig cxConfig, @NonNull Logger logger) throws CxCo
4848 public String authValidate () throws IOException , InterruptedException , CxException {
4949 this .logger .info ("initialized authentication validation command" );
5050
51- List <String > arguments = commonArguments ();
51+ List <String > arguments = new ArrayList <> ();
5252 arguments .add (CxConstants .CMD_AUTH );
5353 arguments .add (CxConstants .SUB_CMD_VALIDATE );
5454
55- return Execution .executeCommand (arguments , logger , (line ) -> line );
55+ return Execution .executeCommand (withConfigArguments ( arguments ) , logger , (line ) -> line );
5656 }
5757
5858 public Scan scanShow (@ NonNull UUID scanId ) throws IOException , InterruptedException , CxException {
5959 this .logger .info ("initialized scan retrieval for id: {}" , scanId );
6060
61- List <String > arguments = commonArguments ();
62- arguments .addAll (jsonArguments ());
61+ List <String > arguments = new ArrayList <>();
6362 arguments .add (CxConstants .CMD_SCAN );
6463 arguments .add (CxConstants .SUB_CMD_SHOW );
6564 arguments .add (CxConstants .SCAN_ID );
6665 arguments .add (scanId .toString ());
66+ arguments .addAll (jsonArguments ());
6767
68- return Execution .executeCommand (arguments , logger , Scan ::fromLine );
68+ return Execution .executeCommand (withConfigArguments ( arguments ) , logger , Scan ::fromLine );
6969 }
7070
7171 public List <Scan > scanList () throws IOException , InterruptedException , CxException {
@@ -75,16 +75,16 @@ public List<Scan> scanList() throws IOException, InterruptedException, CxExcepti
7575 public List <Scan > scanList (String filter ) throws IOException , InterruptedException , CxException {
7676 this .logger .info ("initialized retrieval for scan list {}" , filter );
7777
78- List <String > arguments = commonArguments ();
79- arguments .addAll (jsonArguments ());
78+ List <String > arguments = new ArrayList <>();
8079 arguments .add (CxConstants .CMD_SCAN );
8180 arguments .add (CxConstants .SUB_CMD_LIST );
81+ arguments .addAll (jsonArguments ());
8282 if (StringUtils .isNotBlank (filter )) {
8383 arguments .add (CxConstants .FILTER );
8484 arguments .add (filter );
8585 }
8686
87- return Execution .executeCommand (arguments , logger , Scan ::listFromLine );
87+ return Execution .executeCommand (withConfigArguments ( arguments ) , logger , Scan ::listFromLine );
8888 }
8989
9090 public Scan scanCreate (@ NonNull Map <String , String > params ) throws IOException , InterruptedException , CxException {
@@ -95,10 +95,10 @@ public Scan scanCreate(@NonNull Map<String, String> params, String additionalPar
9595 throws IOException , InterruptedException , CxException {
9696 this .logger .info ("initialized scan create command" );
9797
98- List <String > arguments = commonArguments ();
99- arguments .addAll (jsonArguments ());
98+ List <String > arguments = new ArrayList <>();
10099 arguments .add (CxConstants .CMD_SCAN );
101100 arguments .add (CxConstants .SUB_CMD_CREATE );
101+ arguments .addAll (jsonArguments ());
102102
103103 for (Map .Entry <String , String > param : params .entrySet ()) {
104104 arguments .add (param .getKey ());
@@ -107,20 +107,20 @@ public Scan scanCreate(@NonNull Map<String, String> params, String additionalPar
107107
108108 arguments .addAll (CxConfig .parseAdditionalParameters (additionalParameters ));
109109
110- return Execution .executeCommand (arguments , logger , Scan ::fromLine );
110+ return Execution .executeCommand (withConfigArguments ( arguments ) , logger , Scan ::fromLine );
111111 }
112112
113113 public Project projectShow (@ NonNull UUID projectId ) throws IOException , InterruptedException , CxException {
114114 this .logger .info ("initialized project retrieval for id: {}" , projectId );
115115
116- List <String > arguments = commonArguments ();
117- arguments .addAll (jsonArguments ());
116+ List <String > arguments = new ArrayList <>();
118117 arguments .add (CxConstants .CMD_PROJECT );
119118 arguments .add (CxConstants .SUB_CMD_SHOW );
120119 arguments .add (CxConstants .PROJECT_ID );
121120 arguments .add (projectId .toString ());
121+ arguments .addAll (jsonArguments ());
122122
123- return Execution .executeCommand (arguments , logger , Project ::fromLine );
123+ return Execution .executeCommand (withConfigArguments ( arguments ) , logger , Project ::fromLine );
124124 }
125125
126126 public List <Project > projectList () throws IOException , InterruptedException , CxException {
@@ -130,16 +130,16 @@ public List<Project> projectList() throws IOException, InterruptedException, CxE
130130 public List <Project > projectList (String filter ) throws IOException , InterruptedException , CxException {
131131 this .logger .info ("initialized retrieval for project list {}" , filter );
132132
133- List <String > arguments = commonArguments ();
134- arguments .addAll (jsonArguments ());
133+ List <String > arguments = new ArrayList <>();
135134 arguments .add (CxConstants .CMD_PROJECT );
136135 arguments .add (CxConstants .SUB_CMD_LIST );
137136 if (StringUtils .isNotBlank (filter )) {
138137 arguments .add (CxConstants .FILTER );
139138 arguments .add (filter );
140139 }
140+ arguments .addAll (jsonArguments ());
141141
142- return Execution .executeCommand (arguments , logger , Project ::listFromLine );
142+ return Execution .executeCommand (withConfigArguments ( arguments ) , logger , Project ::listFromLine );
143143 }
144144
145145 public Results results (@ NonNull UUID scanId ) throws IOException , InterruptedException , CxException {
@@ -155,7 +155,7 @@ public String results(@NonNull UUID scanId, ReportFormat reportFormat)
155155 String tempDir = Files .createTempDirectory ("cx" ).toAbsolutePath ().toString ();
156156 String fileName = Long .toString (System .nanoTime ());
157157
158- List <String > arguments = commonArguments ();
158+ List <String > arguments = new ArrayList <> ();
159159 arguments .add (CxConstants .CMD_RESULT );
160160 arguments .add (CxConstants .SCAN_ID );
161161 arguments .add (scanId .toString ());
@@ -166,15 +166,16 @@ public String results(@NonNull UUID scanId, ReportFormat reportFormat)
166166 arguments .add (CxConstants .OUTPUT_PATH );
167167 arguments .add (tempDir );
168168
169- return Execution .executeCommand (arguments ,
169+ return Execution .executeCommand (withConfigArguments ( arguments ) ,
170170 logger , tempDir ,
171171 fileName + reportFormat .getExtension ());
172172 }
173173
174- private List <String > commonArguments ( ) {
174+ private List <String > withConfigArguments ( List < String > commands ) {
175175 List <String > arguments = new ArrayList <>();
176176
177177 arguments .add (this .executable .getPath ());
178+ arguments .addAll (commands );
178179 arguments .addAll (this .cxConfig .toArguments ());
179180
180181 return arguments ;
0 commit comments