Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## 1.8.6

- Add a menu option to update the version of the Aqua plugin

## 1.8.5

- Add support for detecting cursor to enable MCP menu
Expand Down
11 changes: 10 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"publisher": "AquaSecurityOfficial",
"description": "Find vulnerabilities, misconfigurations and exposed secrets in your code",
"icon": "images/icon.png",
"version": "1.8.5",
"version": "1.8.6",
"engines": {
"vscode": "^1.56.0"
},
Expand Down Expand Up @@ -327,6 +327,10 @@
"command": "trivy.useAquaPlatform",
"title": "Use Aqua Platform"
},
{
"command": "trivy.updateAquaPlugin",
"title": "Update Aqua Platform Plugin"
},
{
"command": "trivy.disableUseAquaPlatform",
"title": "✓ Use Aqua Platform"
Expand Down Expand Up @@ -514,6 +518,11 @@
"when": "view == trivyIssueViewer && trivy.sastScanning && trivy.useAquaPlatform",
"group": "4_aquaPlatform@7"
},
{
"command": "trivy.updateAquaPlugin",
"when": "view == trivyIssueViewer && trivy.useAquaPlatform",
"group": "4_aquaPlatform@8"
},
{
"command": "trivy.setupCommercial",
"when": "view == trivyIssueViewer",
Expand Down
6 changes: 6 additions & 0 deletions src/activate_commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,12 @@ export function registerCommands(
() => trivyWrapper.showCurrentTrivyVersion(),
'Failed to get Trivy version'
);
registerCommand(
context,
'trivy.updateAquaPlugin',
() => trivyWrapper.updateAquaPlugin(),
'Failed to update aqua plugin'
);
registerCommand(context, 'trivy.refresh', () => {
misconfigProvider.refresh();
assuranceProvider.refresh();
Expand Down
59 changes: 59 additions & 0 deletions src/command/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,19 @@ export class TrivyWrapper {
}
}

/**
* Update the Aqua Platform plugin
*/
async updateAquaPlugin(): Promise<void> {
try {
await this.updateAquaPluginVersion();
} catch (error) {
const errorMessage =
error instanceof Error ? error.message : String(error);
showErrorMessage(`Failed to update aqua plugin: ${errorMessage}`);
}
}

/**
* Scan a specific workspace folder
* @param workspaceFolder The workspace folder to scan
Expand Down Expand Up @@ -402,6 +415,52 @@ export class TrivyWrapper {
});
}

/**
* Update the Aqua Platform plugin version
* @returns Promise resolving when the update is complete
*/
async updateAquaPluginVersion() {
if (!this.checkTrivyInstalled()) {
showErrorMessage('Trivy could not be found, check Output window');
return;
}

const binary = this.getBinaryPath();

return new Promise<string>((resolve, reject) => {
this.outputChannel.getOutputChannel().show(true);
try {
const process = child.exec(`"${binary}" plugin upgrade aqua`);

process.stdout?.on('data', (data) => {
this.outputChannel.appendLine(`${data.toString()}`);
});

process.stderr?.on('data', (data) => {
this.outputChannel.appendLine(`${data.toString()}`);
const result = data.toString();
if (result.includes('Plugin upgraded')) {
showInformationMessage(
'Aqua Platform plugin upgraded successfully'
);
resolve('');
} else if (result.includes('The plugin is up-to-date')) {
showInformationMessage(
'Aqua Platform plugin is already up-to-date'
);
resolve('');
}
});

process.on('error', (error) => {
reject(error);
});
} catch (error) {
reject(error);
}
});
}

/**
* Build the Trivy command
* @param workingPath Path to scan
Expand Down