Skip to content

Commit fe1cc78

Browse files
author
lixiaolong
committed
[fix] 修改README.md
1 parent 0f9a1e2 commit fe1cc78

File tree

4 files changed

+120
-116
lines changed

4 files changed

+120
-116
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<img alt="logo" src="https://opensca.xmirror.cn/docs/img/OpenSCAlogo.png">
33
</p>
44
<h1 align="center" style="margin: 30px 0 30px; font-weight: bold;">OpenSCA Xcheck</h1>
5-
<h4 align="center">IntelliJ平台的OpenSCA Xcheck插件,让代码更安全</h4>
5+
<h4 align="center">VS Code平台的OpenSCA Xcheck插件,让代码更安全</h4>
66
<p align="center">
77
<a href="https://github.com/XmirrorSecurity/OpenSCA-intellij-plugin/blob/master/LICENSE"><img src="https://img.shields.io/github/license/XmirrorSecurity/OpenSCA-intellij-plugin?style=flat-square"></a>
88
<!-- <a href="https://github.com/XmirrorSecurity/OpenSCA-intellij-plugin/releases"><img src="https://img.shields.io/github/v/release/XmirrorSecurity/OpenSCA-intellij-plugin?style=flat-square"></a> -->

src/command/scan.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,15 @@ export default class Scan extends Utils implements IScan {
9999
this.scanProcess.stdout?.on('data', function (data) {
100100
console.log('cli:', String(data));
101101
if (String(data).indexOf('请求资源不存在') !== -1) {
102+
resolve(false);
102103
Loger.error('OpenSCA-cli 运行异常,错误信息:' + data);
103104
vscode.window.showErrorMessage('请求资源不存在,请重新设置token');
105+
vscode.commands.executeCommand(OPENSCA_REFRESH_OPERATION_COMMAND);
104106
} else if (String(data).indexOf('OSS令牌已过期') !== -1) {
107+
resolve(false);
105108
Loger.error('OpenSCA-cli 运行异常,错误信息:' + data);
106109
vscode.window.showErrorMessage('OSS令牌已过期,请重新设置token');
110+
vscode.commands.executeCommand(OPENSCA_REFRESH_OPERATION_COMMAND);
107111
}
108112
});
109113
this.scanProcess.stderr?.on('data', function (data) {

src/common/functions.ts

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,44 @@
1-
import * as os from 'os';
2-
3-
export function getPlatform(): string {
4-
const platform = os.platform(); // win32, sunos, openbsd, linux, freebsd, darwin, aix
5-
const platformMap = new Map([
6-
['win32', 'windows'],
7-
['linux', 'linux'],
8-
['darwin', 'mac'],
9-
]);
10-
return platformMap.get(platform) || 'windows';
11-
}
12-
13-
export function getArch(): string {
14-
const arch = os.arch(); // x64, arm, arm64, ia32
15-
const archMap = new Map([
16-
['x64', 'amd64'],
17-
['arm', 'arm64'],
18-
['arm64', 'arm64'],
19-
['ia32', '386'],
20-
]);
21-
return archMap.get(arch) || '';
22-
}
23-
24-
export function getEngineCliName(): string {
25-
const platform = os.platform(); // win32, sunos, openbsd, linux, freebsd, darwin, aix
26-
const engineCliMap = new Map([
27-
['win32', 'opensca-cli.exe'],
28-
['linux', 'opensca-cli'],
29-
['darwin', 'opensca-cli'],
30-
]);
31-
return engineCliMap.get(platform) || 'opensca-cli';
32-
}
33-
34-
export function getIdentity() {
35-
const _random = (len: number): string => {
36-
const t = 'qwertyuiopasdfghjklzxcvbnm1234567890';
37-
let val = '';
38-
for (let i = 0; i < len; i++) {
39-
val += t.charAt(Math.floor(Math.random() * t.length));
40-
}
41-
return val;
42-
};
43-
return `${_random(8)}-${_random(4)}-${_random(4)}-${_random(4)}-${_random(12)}`;
44-
}
1+
import * as os from 'os';
2+
3+
export function getPlatform(): string {
4+
const platform = os.platform(); // win32, sunos, openbsd, linux, freebsd, darwin, aix
5+
const platformMap = new Map([
6+
['win32', 'windows'],
7+
['linux', 'linux'],
8+
['darwin', 'mac'],
9+
]);
10+
return platformMap.get(platform) || 'windows';
11+
}
12+
13+
export function getArch(): string {
14+
const arch = os.arch(); // x64, arm, arm64, ia32
15+
const archMap = new Map([
16+
['x64', 'amd64'],
17+
['arm', 'arm64'],
18+
['arm64', 'arm64'],
19+
['ia32', '386'],
20+
]);
21+
return archMap.get(arch) || '';
22+
}
23+
24+
export function getEngineCliName(): string {
25+
const platform = os.platform(); // win32, sunos, openbsd, linux, freebsd, darwin, aix
26+
const engineCliMap = new Map([
27+
['win32', 'opensca-cli.exe'],
28+
['linux', 'opensca-cli'],
29+
['darwin', 'opensca-cli'],
30+
]);
31+
return engineCliMap.get(platform) || 'opensca-cli';
32+
}
33+
34+
export function getIdentity() {
35+
const _random = (len: number): string => {
36+
const t = 'qwertyuiopasdfghjklzxcvbnm1234567890';
37+
let val = '';
38+
for (let i = 0; i < len; i++) {
39+
val += t.charAt(Math.floor(Math.random() * t.length));
40+
}
41+
return val;
42+
};
43+
return `${_random(8)}-${_random(4)}-${_random(4)}-${_random(4)}-${_random(12)}`;
44+
}

src/provider/OperationProvider.ts

Lines changed: 71 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,71 @@
1-
import * as vscode from 'vscode';
2-
import Scan from '../command/scan';
3-
import { OPENSCA_CLEAR_SCANRESULT_COMMAND, OPENSCA_SCAN_COMMAND, OPENSCA_SETTING_COMMAND, OPENSCA_STOP_COMMAND, OPENSCA_TESTCONF_COMMAND, OPENSCA_VIEW_COMMAND, VSCODE_OPEN_COMMAND } from '../common/commands';
4-
import { iconPathBtnClear, iconPathBtnHelp, iconPathBtnMore, iconPathBtnRun, iconPathBtnRunActive, iconPathBtnSetting, iconPathBtnStop, iconPathBtnStopActive, iconPathBtnTest } from '../common/img';
5-
import { TreeItem } from '../common/utils';
6-
7-
export class OperationProvider implements vscode.TreeDataProvider<TreeItem> {
8-
protected scan: Scan | undefined = undefined;
9-
private _onDidChangeTreeData: vscode.EventEmitter<TreeItem | undefined | void> = new vscode.EventEmitter<TreeItem | undefined | void>();
10-
readonly onDidChangeTreeData: vscode.Event<TreeItem | undefined | void> = this._onDidChangeTreeData.event;
11-
12-
constructor(
13-
private workspaceRoot: string | undefined,
14-
scan: Scan | undefined
15-
) {
16-
this.scan = scan;
17-
}
18-
19-
refresh(): void {
20-
this._onDidChangeTreeData.fire();
21-
}
22-
23-
getTreeItem(element: TreeItem): vscode.TreeItem {
24-
return element;
25-
}
26-
27-
getChildren(): Promise<TreeItem[]> {
28-
if (!this.workspaceRoot) {
29-
vscode.window.showInformationMessage('当前窗口没有扫描项目');
30-
return Promise.resolve([]);
31-
}
32-
33-
return Promise.resolve([
34-
new TreeItem('Run', vscode.TreeItemCollapsibleState.None, this.scan?.scanProcessRuning ? iconPathBtnRun : iconPathBtnRunActive, '', {
35-
command: OPENSCA_SCAN_COMMAND,
36-
title: '',
37-
arguments: [true],
38-
}),
39-
new TreeItem('Stop', vscode.TreeItemCollapsibleState.None, this.scan?.scanProcessRuning ? iconPathBtnStopActive : iconPathBtnStop, '', {
40-
command: OPENSCA_STOP_COMMAND,
41-
title: '',
42-
arguments: [true],
43-
}),
44-
new TreeItem('Clean', vscode.TreeItemCollapsibleState.None, iconPathBtnClear, '', {
45-
command: OPENSCA_CLEAR_SCANRESULT_COMMAND,
46-
title: '',
47-
arguments: [],
48-
}),
49-
new TreeItem('Test connection', vscode.TreeItemCollapsibleState.None, iconPathBtnTest, '', {
50-
command: OPENSCA_TESTCONF_COMMAND,
51-
title: '',
52-
arguments: [],
53-
}),
54-
new TreeItem('Setting', vscode.TreeItemCollapsibleState.None, iconPathBtnSetting, '', {
55-
command: OPENSCA_SETTING_COMMAND,
56-
title: '',
57-
arguments: [],
58-
}),
59-
new TreeItem('Instructions ', vscode.TreeItemCollapsibleState.None, iconPathBtnHelp, '', {
60-
command: OPENSCA_VIEW_COMMAND,
61-
title: '',
62-
arguments: ['help'],
63-
}),
64-
new TreeItem('See more', vscode.TreeItemCollapsibleState.None, iconPathBtnMore, '', {
65-
command: VSCODE_OPEN_COMMAND,
66-
title: '',
67-
arguments: ['https://opensca.xmirror.cn/docs/v1/'],
68-
}),
69-
]);
70-
}
71-
}
1+
import * as vscode from 'vscode';
2+
import Scan from '../command/scan';
3+
import { OPENSCA_CLEAR_SCANRESULT_COMMAND, OPENSCA_SCAN_COMMAND, OPENSCA_SETTING_COMMAND, OPENSCA_STOP_COMMAND, OPENSCA_TESTCONF_COMMAND, OPENSCA_VIEW_COMMAND, VSCODE_OPEN_COMMAND } from '../common/commands';
4+
import { iconPathBtnClear, iconPathBtnHelp, iconPathBtnMore, iconPathBtnRun, iconPathBtnRunActive, iconPathBtnSetting, iconPathBtnStop, iconPathBtnStopActive, iconPathBtnTest } from '../common/img';
5+
import { TreeItem } from '../common/utils';
6+
7+
export class OperationProvider implements vscode.TreeDataProvider<TreeItem> {
8+
protected scan: Scan | undefined = undefined;
9+
private _onDidChangeTreeData: vscode.EventEmitter<TreeItem | undefined | void> = new vscode.EventEmitter<TreeItem | undefined | void>();
10+
readonly onDidChangeTreeData: vscode.Event<TreeItem | undefined | void> = this._onDidChangeTreeData.event;
11+
12+
constructor(
13+
private workspaceRoot: string | undefined,
14+
scan: Scan | undefined
15+
) {
16+
this.scan = scan;
17+
}
18+
19+
refresh(): void {
20+
this._onDidChangeTreeData.fire();
21+
}
22+
23+
getTreeItem(element: TreeItem): vscode.TreeItem {
24+
return element;
25+
}
26+
27+
getChildren(): Promise<TreeItem[]> {
28+
if (!this.workspaceRoot) {
29+
vscode.window.showInformationMessage('当前窗口没有扫描项目');
30+
return Promise.resolve([]);
31+
}
32+
33+
return Promise.resolve([
34+
new TreeItem('Run', vscode.TreeItemCollapsibleState.None, this.scan?.scanProcessRuning ? iconPathBtnRun : iconPathBtnRunActive, '', {
35+
command: OPENSCA_SCAN_COMMAND,
36+
title: '',
37+
arguments: [true],
38+
}),
39+
new TreeItem('Stop', vscode.TreeItemCollapsibleState.None, this.scan?.scanProcessRuning ? iconPathBtnStopActive : iconPathBtnStop, '', {
40+
command: OPENSCA_STOP_COMMAND,
41+
title: '',
42+
arguments: [true],
43+
}),
44+
new TreeItem('Clean', vscode.TreeItemCollapsibleState.None, iconPathBtnClear, '', {
45+
command: OPENSCA_CLEAR_SCANRESULT_COMMAND,
46+
title: '',
47+
arguments: [],
48+
}),
49+
new TreeItem('Test connection', vscode.TreeItemCollapsibleState.None, iconPathBtnTest, '', {
50+
command: OPENSCA_TESTCONF_COMMAND,
51+
title: '',
52+
arguments: [],
53+
}),
54+
new TreeItem('Setting', vscode.TreeItemCollapsibleState.None, iconPathBtnSetting, '', {
55+
command: OPENSCA_SETTING_COMMAND,
56+
title: '',
57+
arguments: [],
58+
}),
59+
new TreeItem('Instructions ', vscode.TreeItemCollapsibleState.None, iconPathBtnHelp, '', {
60+
command: OPENSCA_VIEW_COMMAND,
61+
title: '',
62+
arguments: ['help'],
63+
}),
64+
new TreeItem('See more', vscode.TreeItemCollapsibleState.None, iconPathBtnMore, '', {
65+
command: VSCODE_OPEN_COMMAND,
66+
title: '',
67+
arguments: ['https://opensca.xmirror.cn/docs/v1/'],
68+
}),
69+
]);
70+
}
71+
}

0 commit comments

Comments
 (0)