1
1
package de .fraunhofer .iem .devassist .analysis ;
2
2
3
+ import com .intellij .ide .util .PropertiesComponent ;
3
4
import com .intellij .openapi .progress .PerformInBackgroundOption ;
4
5
import com .intellij .openapi .progress .ProgressIndicator ;
5
6
import com .intellij .openapi .progress .Task ;
6
7
import com .intellij .openapi .project .Project ;
7
8
import com .intellij .openapi .util .NlsContexts ;
8
9
import com .intellij .util .messages .MessageBus ;
10
+ import de .fraunhofer .iem .aidevassist .sa .cli .AIDevAssistCli ;
11
+ import de .fraunhofer .iem .aidevassist .sa .cli .CliRunner ;
9
12
import de .fraunhofer .iem .devassist .comm .SecucheckNotifier ;
13
+ import de .fraunhofer .iem .devassist .util .Constants ;
10
14
import org .jetbrains .annotations .NotNull ;
11
15
import org .jetbrains .annotations .Nullable ;
16
+ import picocli .CommandLine ;
12
17
13
18
import java .time .LocalDateTime ;
14
19
import java .time .format .DateTimeFormatter ;
15
20
import java .util .HashMap ;
21
+ import java .util .Objects ;
16
22
import java .util .concurrent .TimeUnit ;
17
23
18
24
public class SecucheckBackgroundTask extends Task .Backgroundable {
@@ -31,24 +37,25 @@ public void run(@NotNull ProgressIndicator indicator) {
31
37
32
38
long start = System .currentTimeMillis ();
33
39
34
- //TODO add implementation to run SecuCheck
35
- indicator .setText ("Generating fluentTQL Specifications" );
36
-
37
40
indicator .setText ("Configuring SecuCheck" );
38
41
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" );
45
53
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 () );
50
58
}
51
- indicator .setText ("Exporting analysis results" );
52
59
53
60
MessageBus messageBus = project .getMessageBus ();
54
61
SecucheckNotifier publisher = messageBus .syncPublisher (SecucheckNotifier .END_SECUCHECK_PROCESS_TOPIC );
0 commit comments