From 7324ab3e49a7df7c0448026e8a45d5bf5557373b Mon Sep 17 00:00:00 2001 From: Viacheslav Fateev Date: Fri, 12 Jun 2026 13:22:16 +0300 Subject: [PATCH 1/2] Fix audits in case of no ast binary found --- .../xliic/openapi/graphql/GraphQlService.java | 38 ++++++++++-------- .../xliic/openapi/services/AuditService.java | 40 ++++++++++--------- 2 files changed, 43 insertions(+), 35 deletions(-) diff --git a/openapi-plugin/src/main/java/com/xliic/openapi/graphql/GraphQlService.java b/openapi-plugin/src/main/java/com/xliic/openapi/graphql/GraphQlService.java index 0f489cbe..2c406e71 100644 --- a/openapi-plugin/src/main/java/com/xliic/openapi/graphql/GraphQlService.java +++ b/openapi-plugin/src/main/java/com/xliic/openapi/graphql/GraphQlService.java @@ -95,30 +95,34 @@ public void reject(@NotNull String error) { } }; if (type == Credentials.Type.AnondToken) { - CliService.getInstance().downloadOrUpdateIfNecessary(project, new CliService.Callback() { - @Override - public void complete(@NotNull String cliPath) { - startAuditTask(file, new GraphQlCliTask(project, file, type, callback)); - } - @Override - public void reject(@NotNull String error) { - callback.reject(error); - } - @Override - public void cancel() { - pendingAudits.remove(file.getPath()); - MsgUtils.notifyInfo(project, "42Crunch API Security Testing Binary is required to run Audit."); - } - }, true); + runAuditCliTask(file, type, callback); } else if (type == Credentials.Type.ApiToken) { String auditRuntime = SettingsService.getInstance().getValue(Settings.Audit.AUDIT_RUNTIME); if (Objects.equals(auditRuntime, AUDIT_RUNTIME_CLI)) { - startAuditTask(file, new GraphQlCliTask(project, file, type, callback)); + runAuditCliTask(file, type, callback); } else { - startAuditTask(file, new PlatformGraphQlAuditTask(project, file, type, callback)); + startAuditTask(file, new PlatformGraphQlAuditTask(project, file, type, callback)); } } } + + private void runAuditCliTask(VirtualFile file, Credentials.Type type, GraphQlCallback callback) { + CliService.getInstance().downloadOrUpdateIfNecessary(project, new CliService.Callback() { + @Override + public void complete(@NotNull String cliPath) { + startAuditTask(file, new GraphQlCliTask(project, file, type, callback)); + } + @Override + public void reject(@NotNull String error) { + callback.reject(error); + } + @Override + public void cancel() { + pendingAudits.remove(file.getPath()); + MsgUtils.notifyInfo(project, "42Crunch API Security Testing Binary is required to run Audit."); + } + }, true); + } private void startAuditTask(VirtualFile file, Task.Backgroundable task) { ApplicationManager.getApplication().invokeLater(() -> { diff --git a/openapi-plugin/src/main/java/com/xliic/openapi/services/AuditService.java b/openapi-plugin/src/main/java/com/xliic/openapi/services/AuditService.java index 1745108a..d326dd09 100644 --- a/openapi-plugin/src/main/java/com/xliic/openapi/services/AuditService.java +++ b/openapi-plugin/src/main/java/com/xliic/openapi/services/AuditService.java @@ -438,27 +438,11 @@ public void cancel() { boolean isFullAudit = payload == null || payload.isFull(); // Paid users always run audit using the platform, free users use CLI or fallback to anond if (type == Credentials.Type.AnondToken) { - CliService.getInstance().downloadOrUpdateIfNecessary(project, new CliService.Callback() { - @Override - public void complete(@NotNull String cliPath) { - startAuditTask(file, isFullAudit ? - new AuditCliTask(project, type, file, callback) : new AuditCliTask(project, type, payload, callback)); - } - @Override - public void reject(@NotNull String error) { - callback.reject(error); - } - @Override - public void cancel() { - pendingAudits.remove(file.getPath()); - MsgUtils.notifyInfo(project, "42Crunch API Security Testing Binary is required to run Audit."); - } - }, true); + runAuditCliTask(file, payload, type, callback); } else if (type == Credentials.Type.ApiToken) { String auditRuntime = SettingsService.getInstance().getValue(Settings.Audit.AUDIT_RUNTIME); if (Objects.equals(auditRuntime, AUDIT_RUNTIME_CLI)) { - startAuditTask(file, isFullAudit ? - new AuditCliTask(project, type, file, callback) : new AuditCliTask(project, type, payload, callback)); + runAuditCliTask(file, payload, type, callback); } else { startAuditTask(file, isFullAudit ? new PlatformAuditTask(project, file, type, callback) : new PlatformAuditTask(project, payload, type, callback)); @@ -466,6 +450,26 @@ public void cancel() { } } + private void runAuditCliTask(VirtualFile file, AuditOperation payload, Credentials.Type type, Callback callback) { + CliService.getInstance().downloadOrUpdateIfNecessary(project, new CliService.Callback() { + @Override + public void complete(@NotNull String cliPath) { + boolean isFullAudit = payload == null || payload.isFull(); + startAuditTask(file, isFullAudit ? new AuditCliTask(project, type, file, callback) : + new AuditCliTask(project, type, payload, callback)); + } + @Override + public void reject(@NotNull String error) { + callback.reject(error); + } + @Override + public void cancel() { + pendingAudits.remove(file.getPath()); + MsgUtils.notifyInfo(project, "42Crunch API Security Testing Binary is required to run Audit."); + } + }, true); + } + private void startAuditTask(VirtualFile file, Task.Backgroundable task) { ApplicationManager.getApplication().invokeLater(() -> { cleanAuditReport(file); From d395697994a7ccc73157898e830f1df9c091fbda Mon Sep 17 00:00:00 2001 From: Viacheslav Fateev Date: Wed, 8 Jul 2026 12:59:33 +0300 Subject: [PATCH 2/2] Apply temp WA to align logic with the VSCode implementation --- .../main/java/com/xliic/openapi/graphql/GraphQlService.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/openapi-plugin/src/main/java/com/xliic/openapi/graphql/GraphQlService.java b/openapi-plugin/src/main/java/com/xliic/openapi/graphql/GraphQlService.java index 2c406e71..a60d8d31 100644 --- a/openapi-plugin/src/main/java/com/xliic/openapi/graphql/GraphQlService.java +++ b/openapi-plugin/src/main/java/com/xliic/openapi/graphql/GraphQlService.java @@ -101,11 +101,13 @@ public void reject(@NotNull String error) { if (Objects.equals(auditRuntime, AUDIT_RUNTIME_CLI)) { runAuditCliTask(file, type, callback); } else { - startAuditTask(file, new PlatformGraphQlAuditTask(project, file, type, callback)); + // TODO: temp WA to align logic with the VSCode implementation + //startAuditTask(file, new PlatformGraphQlAuditTask(project, file, type, callback)); + runAuditCliTask(file, type, callback); } } } - + private void runAuditCliTask(VirtualFile file, Credentials.Type type, GraphQlCallback callback) { CliService.getInstance().downloadOrUpdateIfNecessary(project, new CliService.Callback() { @Override