11package de .fraunhofer .iem .devassist .analysis ;
22
3+ import com .intellij .ide .util .PropertiesComponent ;
34import com .intellij .openapi .progress .PerformInBackgroundOption ;
45import com .intellij .openapi .progress .ProgressIndicator ;
56import com .intellij .openapi .progress .Task ;
67import com .intellij .openapi .project .Project ;
78import com .intellij .openapi .util .NlsContexts ;
89import com .intellij .util .messages .MessageBus ;
10+ import de .fraunhofer .iem .aidevassist .sa .cli .AIDevAssistCli ;
11+ import de .fraunhofer .iem .aidevassist .sa .cli .CliRunner ;
912import de .fraunhofer .iem .devassist .comm .SecucheckNotifier ;
13+ import de .fraunhofer .iem .devassist .util .Constants ;
1014import org .jetbrains .annotations .NotNull ;
1115import org .jetbrains .annotations .Nullable ;
16+ import picocli .CommandLine ;
1217
1318import java .time .LocalDateTime ;
1419import java .time .format .DateTimeFormatter ;
1520import java .util .HashMap ;
21+ import java .util .Objects ;
1622import java .util .concurrent .TimeUnit ;
1723
1824public class SecucheckBackgroundTask extends Task .Backgroundable {
@@ -31,24 +37,25 @@ public void run(@NotNull ProgressIndicator indicator) {
3137
3238 long start = System .currentTimeMillis ();
3339
34- //TODO add implementation to run SecuCheck
35- indicator .setText ("Generating fluentTQL Specifications" );
36-
3740 indicator .setText ("Configuring SecuCheck" );
3841
39- try {
40- TimeUnit .SECONDS .sleep (2 );
41- } catch (InterruptedException e ) {
42- throw new RuntimeException (e );
43- }
44- indicator .setText ("Configuring analysis" );
42+ String [] args = new String []{
43+ "--analysis" , "0" ,
44+ Objects .requireNonNull (PropertiesComponent .getInstance (project ).getValue (Constants .SOURCE_DIRECTORY )),
45+ "--output" , Objects .requireNonNull (PropertiesComponent .getInstance (project ).getValue (Constants .OUTPUT_DIRECTORY )),
46+ "--inclusion" , "*" ,
47+ "--entry" , "*" };
48+
49+ CliRunner cliRunner = new CliRunner (args );
50+ CommandLine .ParseResult cmd = new CommandLine (cliRunner ).parseArgs (args );
51+
52+ indicator .setText ("Running analysis" );
4553
46- try {
47- TimeUnit . SECONDS . sleep ( 2 );
48- } catch ( InterruptedException e ) {
49- throw new RuntimeException ( e );
54+ if ( cmd . errors (). isEmpty ()) {
55+ AIDevAssistCli cli = new AIDevAssistCli ( );
56+ cli . run ( cliRunner . createOptions ());
57+ PropertiesComponent . getInstance ( project ). setValue ( Constants . LAST_SARIF_FILE , cli . getResults (). getResultFile () );
5058 }
51- indicator .setText ("Exporting analysis results" );
5259
5360 MessageBus messageBus = project .getMessageBus ();
5461 SecucheckNotifier publisher = messageBus .syncPublisher (SecucheckNotifier .END_SECUCHECK_PROCESS_TOPIC );
0 commit comments