@aws/lsp-codewhisperer 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/README.md +19 -0
- package/out/client/sigv4/codewhisperer.d.ts +3 -0
- package/out/client/sigv4/codewhisperer.js +14 -0
- package/out/client/sigv4/codewhisperer.js.map +1 -0
- package/out/client/sigv4/service.json +346 -0
- package/out/client/token/bearer-token-service.json +1627 -0
- package/out/client/token/codewhisperer.d.ts +14 -0
- package/out/client/token/codewhisperer.js +23 -0
- package/out/client/token/codewhisperer.js.map +1 -0
- package/out/index.d.ts +2 -0
- package/out/index.js +19 -0
- package/out/index.js.map +1 -0
- package/out/language-server/auto-trigger/autoTrigger.d.ts +38 -0
- package/out/language-server/auto-trigger/autoTrigger.js +119 -0
- package/out/language-server/auto-trigger/autoTrigger.js.map +1 -0
- package/out/language-server/auto-trigger/autoTrigger.test.d.ts +1 -0
- package/out/language-server/auto-trigger/autoTrigger.test.js +82 -0
- package/out/language-server/auto-trigger/autoTrigger.test.js.map +1 -0
- package/out/language-server/auto-trigger/coefficients.json +405 -0
- package/out/language-server/codeWhispererSecurityScanServer.d.ts +4 -0
- package/out/language-server/codeWhispererSecurityScanServer.js +76 -0
- package/out/language-server/codeWhispererSecurityScanServer.js.map +1 -0
- package/out/language-server/codeWhispererServer.d.ts +7 -0
- package/out/language-server/codeWhispererServer.js +425 -0
- package/out/language-server/codeWhispererServer.js.map +1 -0
- package/out/language-server/codeWhispererServer.test.d.ts +1 -0
- package/out/language-server/codeWhispererServer.test.js +1218 -0
- package/out/language-server/codeWhispererServer.test.js.map +1 -0
- package/out/language-server/codeWhispererService.d.ts +84 -0
- package/out/language-server/codeWhispererService.js +168 -0
- package/out/language-server/codeWhispererService.js.map +1 -0
- package/out/language-server/dependencyGraph/commonUtil.d.ts +2 -0
- package/out/language-server/dependencyGraph/commonUtil.js +20 -0
- package/out/language-server/dependencyGraph/commonUtil.js.map +1 -0
- package/out/language-server/dependencyGraph/constants.d.ts +2 -0
- package/out/language-server/dependencyGraph/constants.js +6 -0
- package/out/language-server/dependencyGraph/constants.js.map +1 -0
- package/out/language-server/dependencyGraph/csharpDependencyGraph.d.ts +27 -0
- package/out/language-server/dependencyGraph/csharpDependencyGraph.js +145 -0
- package/out/language-server/dependencyGraph/csharpDependencyGraph.js.map +1 -0
- package/out/language-server/dependencyGraph/csharpDependencyGraph.test.d.ts +1 -0
- package/out/language-server/dependencyGraph/csharpDependencyGraph.test.js +341 -0
- package/out/language-server/dependencyGraph/csharpDependencyGraph.test.js.map +1 -0
- package/out/language-server/dependencyGraph/dependencyGraph.d.ts +125 -0
- package/out/language-server/dependencyGraph/dependencyGraph.js +152 -0
- package/out/language-server/dependencyGraph/dependencyGraph.js.map +1 -0
- package/out/language-server/dependencyGraph/dependencyGraphFactory.d.ts +15 -0
- package/out/language-server/dependencyGraph/dependencyGraphFactory.js +22 -0
- package/out/language-server/dependencyGraph/dependencyGraphFactory.js.map +1 -0
- package/out/language-server/languageDetection.d.ts +3 -0
- package/out/language-server/languageDetection.js +56 -0
- package/out/language-server/languageDetection.js.map +1 -0
- package/out/language-server/mergeRightUtils.d.ts +6 -0
- package/out/language-server/mergeRightUtils.js +37 -0
- package/out/language-server/mergeRightUtils.js.map +1 -0
- package/out/language-server/mergeRightUtils.test.d.ts +1 -0
- package/out/language-server/mergeRightUtils.test.js +53 -0
- package/out/language-server/mergeRightUtils.test.js.map +1 -0
- package/out/language-server/proxy-server.d.ts +2 -0
- package/out/language-server/proxy-server.js +35 -0
- package/out/language-server/proxy-server.js.map +1 -0
- package/out/language-server/securityScan/securityScanHandler.d.ts +17 -0
- package/out/language-server/securityScan/securityScanHandler.js +139 -0
- package/out/language-server/securityScan/securityScanHandler.js.map +1 -0
- package/out/language-server/securityScan/securityScanHandler.test.d.ts +1 -0
- package/out/language-server/securityScan/securityScanHandler.test.js +170 -0
- package/out/language-server/securityScan/securityScanHandler.test.js.map +1 -0
- package/out/language-server/securityScan/types.d.ts +49 -0
- package/out/language-server/securityScan/types.js +3 -0
- package/out/language-server/securityScan/types.js.map +1 -0
- package/out/language-server/session/sessionManager.d.ts +91 -0
- package/out/language-server/session/sessionManager.js +234 -0
- package/out/language-server/session/sessionManager.js.map +1 -0
- package/out/language-server/session/sessionManager.test.d.ts +1 -0
- package/out/language-server/session/sessionManager.test.js +584 -0
- package/out/language-server/session/sessionManager.test.js.map +1 -0
- package/out/language-server/telemetry/codePercentage.d.ts +17 -0
- package/out/language-server/telemetry/codePercentage.js +82 -0
- package/out/language-server/telemetry/codePercentage.js.map +1 -0
- package/out/language-server/telemetry/codePercentage.test.d.ts +1 -0
- package/out/language-server/telemetry/codePercentage.test.js +85 -0
- package/out/language-server/telemetry/codePercentage.test.js.map +1 -0
- package/out/language-server/telemetry/types.d.ts +68 -0
- package/out/language-server/telemetry/types.js +3 -0
- package/out/language-server/telemetry/types.js.map +1 -0
- package/out/language-server/telemetry/userTriggerDecision.test.d.ts +1 -0
- package/out/language-server/telemetry/userTriggerDecision.test.js +946 -0
- package/out/language-server/telemetry/userTriggerDecision.test.js.map +1 -0
- package/out/language-server/telemetry.test.d.ts +1 -0
- package/out/language-server/telemetry.test.js +96 -0
- package/out/language-server/telemetry.test.js.map +1 -0
- package/out/language-server/testUtils.d.ts +69 -0
- package/out/language-server/testUtils.js +90 -0
- package/out/language-server/testUtils.js.map +1 -0
- package/out/language-server/utils.d.ts +6 -0
- package/out/language-server/utils.js +31 -0
- package/out/language-server/utils.js.map +1 -0
- package/package.json +53 -0
- package/script/generateServiceClient.ts +242 -0
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const assert = require("assert");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const Sinon = require("sinon");
|
|
6
|
+
const csharpDependencyGraph_1 = require("./csharpDependencyGraph");
|
|
7
|
+
describe('test CsharpDependencyGraph', () => {
|
|
8
|
+
let csharpDependencyGraph;
|
|
9
|
+
const mockedGetWorkspaceFolder = Sinon.mock();
|
|
10
|
+
const projectPathUri = path.resolve(path.join(__dirname, 'sampleWs'));
|
|
11
|
+
const tempDirPath = path.resolve('\\Temp');
|
|
12
|
+
const mockedFs = {
|
|
13
|
+
copy: Sinon.mock(),
|
|
14
|
+
exists: Sinon.mock(),
|
|
15
|
+
getFileSize: Sinon.mock(),
|
|
16
|
+
getTempDirPath: () => tempDirPath,
|
|
17
|
+
readdir: Sinon.stub(),
|
|
18
|
+
readFile: Sinon.stub(),
|
|
19
|
+
isFile: Sinon.mock(),
|
|
20
|
+
remove: Sinon.mock(),
|
|
21
|
+
};
|
|
22
|
+
const mockedWorkspace = {
|
|
23
|
+
getTextDocument: Sinon.mock(),
|
|
24
|
+
getWorkspaceFolder: mockedGetWorkspaceFolder,
|
|
25
|
+
fs: mockedFs,
|
|
26
|
+
};
|
|
27
|
+
before(() => {
|
|
28
|
+
csharpDependencyGraph = new csharpDependencyGraph_1.CsharpDependencyGraph(mockedWorkspace);
|
|
29
|
+
});
|
|
30
|
+
beforeEach(() => {
|
|
31
|
+
mockedGetWorkspaceFolder.reset();
|
|
32
|
+
mockedGetWorkspaceFolder.returns(undefined);
|
|
33
|
+
csharpDependencyGraph = new csharpDependencyGraph_1.CsharpDependencyGraph(mockedWorkspace);
|
|
34
|
+
});
|
|
35
|
+
describe('Test getPayloadSizeLimitInBytes', () => {
|
|
36
|
+
it('should return correct payload size', () => {
|
|
37
|
+
const expectedPayloadSize = Math.pow(2, 20);
|
|
38
|
+
assert.equal(csharpDependencyGraph.getPayloadSizeLimitInBytes(), expectedPayloadSize);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
describe('Test getProjectName', () => {
|
|
42
|
+
beforeEach(() => {
|
|
43
|
+
mockedFs.isFile.reset();
|
|
44
|
+
mockedFs.isFile.resolves(false);
|
|
45
|
+
});
|
|
46
|
+
it('should return current folder name for given file path outside workspace folder', async () => {
|
|
47
|
+
mockedFs.isFile.resolves(true);
|
|
48
|
+
assert.equal(await csharpDependencyGraph.getProjectName(path.join(projectPathUri, 'sample.cs')), 'sampleWs');
|
|
49
|
+
});
|
|
50
|
+
it('should return correct project name for given forlder path within workspace folder', async () => {
|
|
51
|
+
const expectedProjectName = 'sampleWs';
|
|
52
|
+
mockedGetWorkspaceFolder.returns({ uri: projectPathUri, name: expectedProjectName });
|
|
53
|
+
assert.equal(await csharpDependencyGraph.getProjectName(path.join(projectPathUri, 'src')), expectedProjectName);
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
describe('Test getProjectPath', () => {
|
|
57
|
+
beforeEach(() => {
|
|
58
|
+
mockedFs.isFile.reset();
|
|
59
|
+
mockedFs.isFile.resolves(false);
|
|
60
|
+
});
|
|
61
|
+
it('should not find workspace folder path for given path', async () => {
|
|
62
|
+
const fileFolderPath = path.resolve('\\workspace\\src');
|
|
63
|
+
const fileUri = path.join(fileFolderPath, 'sample.cs');
|
|
64
|
+
mockedFs.isFile.resolves(true);
|
|
65
|
+
const response = await csharpDependencyGraph.getProjectPath(fileUri);
|
|
66
|
+
assert.equal(response, fileFolderPath);
|
|
67
|
+
});
|
|
68
|
+
it('should return project name for within project file', async () => {
|
|
69
|
+
const expectedProjectName = 'sampleWs';
|
|
70
|
+
mockedGetWorkspaceFolder.returns({ uri: projectPathUri, name: expectedProjectName });
|
|
71
|
+
assert.equal(await csharpDependencyGraph.getProjectPath(path.join(projectPathUri, 'src')), projectPathUri);
|
|
72
|
+
mockedGetWorkspaceFolder.reset();
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
describe('Test getReadableSizeLimit', () => {
|
|
76
|
+
it('should return size 1 MB', () => {
|
|
77
|
+
assert.equal(csharpDependencyGraph.getReadableSizeLimit(), '1MB');
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
describe('Test exceedsSizeLimit', () => {
|
|
81
|
+
it('should not exceed size limit', () => {
|
|
82
|
+
const size = 100;
|
|
83
|
+
const expectedResult = false;
|
|
84
|
+
assert.equal(csharpDependencyGraph.exceedsSizeLimit(size), expectedResult);
|
|
85
|
+
});
|
|
86
|
+
it('should exceed size limit', () => {
|
|
87
|
+
const size = Math.pow(2, 21);
|
|
88
|
+
const expectedResult = true;
|
|
89
|
+
assert.equal(csharpDependencyGraph.exceedsSizeLimit(size), expectedResult);
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
describe('Test createNamespaceFilenameMapper', () => {
|
|
93
|
+
beforeEach(() => {
|
|
94
|
+
mockedFs.readdir.reset();
|
|
95
|
+
mockedFs.readFile.reset();
|
|
96
|
+
mockedFs.readdir.resolves([
|
|
97
|
+
{
|
|
98
|
+
isFile: () => false,
|
|
99
|
+
isDirectory: () => true,
|
|
100
|
+
name: 'src',
|
|
101
|
+
path: projectPathUri,
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
isFile: () => true,
|
|
105
|
+
isDirectory: () => false,
|
|
106
|
+
name: 'sample.cs',
|
|
107
|
+
path: path.join(projectPathUri, 'src'),
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
isFile: () => true,
|
|
111
|
+
isDirectory: () => false,
|
|
112
|
+
name: 'model.cs',
|
|
113
|
+
path: path.join(projectPathUri, 'src'),
|
|
114
|
+
},
|
|
115
|
+
]);
|
|
116
|
+
});
|
|
117
|
+
it('should create the map with namespace to filepath mapping', async () => {
|
|
118
|
+
csharpDependencyGraph.namespaceToFilepathDirectory = new Map();
|
|
119
|
+
mockedFs.readFile.callsFake(async (filePath) => {
|
|
120
|
+
if (filePath === path.join(projectPathUri, 'src', 'sample.cs')) {
|
|
121
|
+
return `namespace Amazon.Cw.Utils.Sample {}`;
|
|
122
|
+
}
|
|
123
|
+
if (filePath === path.join(projectPathUri, 'src', 'model.cs')) {
|
|
124
|
+
return `namespace Amazon.Cw.Model {}`;
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
await csharpDependencyGraph.createNamespaceFilenameMapper(projectPathUri);
|
|
128
|
+
assert.deepEqual(csharpDependencyGraph.namespaceToFilepathDirectory, new Map([
|
|
129
|
+
['Amazon.Cw.Model', new Set([path.join(projectPathUri, 'src', 'model.cs')])],
|
|
130
|
+
['Amazon.Cw.Utils.Sample', new Set([path.join(projectPathUri, 'src', 'sample.cs')])],
|
|
131
|
+
]));
|
|
132
|
+
});
|
|
133
|
+
it('should create empty map', async () => {
|
|
134
|
+
csharpDependencyGraph.namespaceToFilepathDirectory = new Map();
|
|
135
|
+
mockedFs.readFile.callsFake(async (filePath) => {
|
|
136
|
+
if (filePath === path.join(projectPathUri, 'src', 'sample.cs')) {
|
|
137
|
+
return `using static Amazon.Cw.Sample;`;
|
|
138
|
+
}
|
|
139
|
+
if (filePath === path.join(projectPathUri, 'src', 'model.cs')) {
|
|
140
|
+
return ``;
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
await csharpDependencyGraph.createNamespaceFilenameMapper(projectPathUri);
|
|
144
|
+
assert.deepEqual(csharpDependencyGraph.namespaceToFilepathDirectory, new Map([]));
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
describe('Test searchDependency', () => {
|
|
148
|
+
beforeEach(() => {
|
|
149
|
+
mockedFs.getFileSize.reset();
|
|
150
|
+
mockedFs.readFile.reset();
|
|
151
|
+
csharpDependencyGraph.namespaceToFilepathDirectory = new Map([
|
|
152
|
+
['Amazon.Cw.Model', new Set([path.join(projectPathUri, 'src', 'model.cs')])],
|
|
153
|
+
['Amazon.Cw.Utils.Sample', new Set([path.join(projectPathUri, 'src', 'sample.cs')])],
|
|
154
|
+
[
|
|
155
|
+
'Amazon.Cw.Props',
|
|
156
|
+
new Set([
|
|
157
|
+
path.join(projectPathUri, 'src', 'interface', 'model.cs'),
|
|
158
|
+
path.join(projectPathUri, 'src', 'interface', 'recommendations.cs'),
|
|
159
|
+
]),
|
|
160
|
+
],
|
|
161
|
+
]);
|
|
162
|
+
});
|
|
163
|
+
it('should return source file only for no dependencies', async () => {
|
|
164
|
+
mockedFs.readFile.resolves(`var total = 5 + 4;`);
|
|
165
|
+
mockedFs.getFileSize.resolves({ size: 1000 });
|
|
166
|
+
const filePath = path.join(projectPathUri, 'main.cs');
|
|
167
|
+
const pickedSourceFiles = await csharpDependencyGraph.searchDependency(filePath);
|
|
168
|
+
assert.deepEqual(pickedSourceFiles, new Set([filePath]));
|
|
169
|
+
});
|
|
170
|
+
it("should return source file with its dependecies' file path", async () => {
|
|
171
|
+
mockedFs.getFileSize.atLeast(1).resolves({ size: 1000 });
|
|
172
|
+
mockedFs.readFile.onFirstCall().resolves(`using Amazon.Cw.Props;
|
|
173
|
+
var total = 5 + 4;`);
|
|
174
|
+
const pickedSourceFiles = await csharpDependencyGraph.searchDependency(path.join(projectPathUri, 'main.cs'));
|
|
175
|
+
assert.deepEqual(pickedSourceFiles, new Set([
|
|
176
|
+
path.join(projectPathUri, 'main.cs'),
|
|
177
|
+
path.join(projectPathUri, 'src', 'interface', 'recommendations.cs'),
|
|
178
|
+
path.join(projectPathUri, 'src', 'interface', 'model.cs'),
|
|
179
|
+
]));
|
|
180
|
+
});
|
|
181
|
+
it("should return source file with its dependecies' until it reaches to payload size limit", async () => {
|
|
182
|
+
mockedFs.getFileSize.onFirstCall().resolves({ size: Math.pow(2, 19) });
|
|
183
|
+
mockedFs.getFileSize.onSecondCall().resolves({ size: Math.pow(2, 19) });
|
|
184
|
+
mockedFs.readFile.onFirstCall().resolves(`using Amazon.Cw.Props;
|
|
185
|
+
var total = 5 + 4;`);
|
|
186
|
+
const pickedSourceFiles = await csharpDependencyGraph.searchDependency(path.join(projectPathUri, 'main.cs'));
|
|
187
|
+
assert.deepEqual(pickedSourceFiles, new Set([
|
|
188
|
+
path.join(projectPathUri, 'main.cs'),
|
|
189
|
+
path.join(projectPathUri, 'src', 'interface', 'model.cs'),
|
|
190
|
+
]));
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
describe('Test traverseDir', () => {
|
|
194
|
+
beforeEach(() => {
|
|
195
|
+
mockedFs.getFileSize.reset();
|
|
196
|
+
mockedFs.readFile.reset();
|
|
197
|
+
mockedFs.readdir.reset();
|
|
198
|
+
csharpDependencyGraph.namespaceToFilepathDirectory = new Map([
|
|
199
|
+
['Amazon.Cw.Model', new Set([path.join(projectPathUri, 'src', 'model.cs')])],
|
|
200
|
+
['Amazon.Cw.Utils.Sample', new Set([path.join(projectPathUri, 'src', 'sample.cs')])],
|
|
201
|
+
[
|
|
202
|
+
'Amazon.Cw.Props',
|
|
203
|
+
new Set([
|
|
204
|
+
path.join(projectPathUri, 'src', 'interface', 'scan.cs'),
|
|
205
|
+
path.join(projectPathUri, 'src', 'interface', 'recommendations.cs'),
|
|
206
|
+
]),
|
|
207
|
+
],
|
|
208
|
+
]);
|
|
209
|
+
mockedFs.readdir.resolves([
|
|
210
|
+
{
|
|
211
|
+
isFile: () => false,
|
|
212
|
+
isDirectory: () => true,
|
|
213
|
+
name: 'src',
|
|
214
|
+
path: projectPathUri,
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
isFile: () => true,
|
|
218
|
+
isDirectory: () => false,
|
|
219
|
+
name: 'sample.cs',
|
|
220
|
+
path: path.join(projectPathUri, 'src'),
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
isFile: () => true,
|
|
224
|
+
isDirectory: () => false,
|
|
225
|
+
name: 'model.cs',
|
|
226
|
+
path: path.join(projectPathUri, 'src'),
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
isFile: () => true,
|
|
230
|
+
isDirectory: () => false,
|
|
231
|
+
name: 'scan.cs',
|
|
232
|
+
path: path.join(projectPathUri, 'src', 'props'),
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
isFile: () => true,
|
|
236
|
+
isDirectory: () => false,
|
|
237
|
+
name: 'recommendation.cs',
|
|
238
|
+
path: path.join(projectPathUri, 'src', 'props'),
|
|
239
|
+
},
|
|
240
|
+
]);
|
|
241
|
+
});
|
|
242
|
+
it('should return without traversing due to payload size limit reached', async () => {
|
|
243
|
+
mockedFs.getFileSize.resolves({ size: Math.pow(2, 20) });
|
|
244
|
+
await csharpDependencyGraph.searchDependency(path.join(projectPathUri, 'main.cs'));
|
|
245
|
+
await csharpDependencyGraph.traverseDir(projectPathUri);
|
|
246
|
+
assert.equal(mockedFs.readFile.calledWith(projectPathUri), false);
|
|
247
|
+
});
|
|
248
|
+
it('should traverse through files until it reaches payload size limit', async () => {
|
|
249
|
+
mockedFs.getFileSize.atLeast(1).resolves({ size: Math.pow(2, 19) });
|
|
250
|
+
await csharpDependencyGraph.traverseDir(projectPathUri);
|
|
251
|
+
assert.strictEqual(csharpDependencyGraph.isProjectTruncated, true);
|
|
252
|
+
});
|
|
253
|
+
it('should traverse through all files', async () => {
|
|
254
|
+
mockedFs.getFileSize.atLeast(1).resolves({ size: Math.pow(2, 10) });
|
|
255
|
+
await csharpDependencyGraph.traverseDir(projectPathUri);
|
|
256
|
+
assert.strictEqual(csharpDependencyGraph.isProjectTruncated, false);
|
|
257
|
+
});
|
|
258
|
+
});
|
|
259
|
+
describe('Test getDependencies', () => {
|
|
260
|
+
beforeEach(() => {
|
|
261
|
+
csharpDependencyGraph.namespaceToFilepathDirectory = new Map([
|
|
262
|
+
['Amazon.Cw.Model', new Set([path.join(projectPathUri, 'src', 'model.cs')])],
|
|
263
|
+
['Amazon.Cw.Utils.Sample', new Set([path.join(projectPathUri, 'src', 'sample.cs')])],
|
|
264
|
+
[
|
|
265
|
+
'Amazon.Cw.Props',
|
|
266
|
+
new Set([
|
|
267
|
+
path.join(projectPathUri, 'src', 'interface', 'scan.cs'),
|
|
268
|
+
path.join(projectPathUri, 'src', 'interface', 'recommendations.cs'),
|
|
269
|
+
]),
|
|
270
|
+
],
|
|
271
|
+
]);
|
|
272
|
+
});
|
|
273
|
+
it('should return file paths for given imports', () => {
|
|
274
|
+
const expectedResponse = new Set([
|
|
275
|
+
path.join(projectPathUri, 'src', 'model.cs'),
|
|
276
|
+
path.join(projectPathUri, 'src', 'sample.cs'),
|
|
277
|
+
]);
|
|
278
|
+
assert.deepEqual(csharpDependencyGraph.getDependencies(['Amazon.Cw.Utils.Sample', 'Amazon.Cw.Model']), expectedResponse);
|
|
279
|
+
});
|
|
280
|
+
it('should return empty list', () => {
|
|
281
|
+
assert.deepEqual(csharpDependencyGraph.getDependencies(['Amazon.Cw']), new Set());
|
|
282
|
+
});
|
|
283
|
+
});
|
|
284
|
+
describe('Test readImports', () => {
|
|
285
|
+
it('should return list of imports ', () => {
|
|
286
|
+
const content = `
|
|
287
|
+
global using static Amazon.Cw.Utils;
|
|
288
|
+
using Amazon.Cw.Model;
|
|
289
|
+
using Proto = Amazon.Cw.Prototypes;
|
|
290
|
+
namespace Amazon.Toolkit.Demo {
|
|
291
|
+
class Main {
|
|
292
|
+
pulbic print() {
|
|
293
|
+
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
`;
|
|
298
|
+
const response = csharpDependencyGraph.readImports(content);
|
|
299
|
+
const expectedImports = ['Amazon.Cw.Utils', 'Amazon.Cw.Model', 'Amazon.Cw.Prototypes'];
|
|
300
|
+
assert.deepEqual(response, expectedImports);
|
|
301
|
+
});
|
|
302
|
+
it('should return empty list', () => {
|
|
303
|
+
const content = `
|
|
304
|
+
namespace Amazon.Toolkit.Demo {
|
|
305
|
+
class Main {
|
|
306
|
+
pulbic print() {
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
`;
|
|
311
|
+
const response = csharpDependencyGraph.readImports(content);
|
|
312
|
+
assert.deepEqual(response, []);
|
|
313
|
+
});
|
|
314
|
+
});
|
|
315
|
+
describe('Test generateTruncation', () => {
|
|
316
|
+
before(() => {
|
|
317
|
+
Sinon.stub(Date, 'now').returns(111111111);
|
|
318
|
+
});
|
|
319
|
+
it('should call zip dir', async () => {
|
|
320
|
+
const zipSize = Math.pow(2, 19);
|
|
321
|
+
const zipFileBuffer = 'dummy-zip-data';
|
|
322
|
+
mockedFs.getFileSize.atLeast(1).resolves({ size: zipSize });
|
|
323
|
+
csharpDependencyGraph.createZip = Sinon.stub().returns({
|
|
324
|
+
zipFileBuffer,
|
|
325
|
+
zipFileSize: zipSize,
|
|
326
|
+
});
|
|
327
|
+
const expectedResult = {
|
|
328
|
+
rootDir: path.join(tempDirPath, 'codewhisperer_scan_111111111'),
|
|
329
|
+
zipFileBuffer,
|
|
330
|
+
scannedFiles: new Set([path.join(projectPathUri, 'main.cs')]),
|
|
331
|
+
srcPayloadSizeInBytes: 0,
|
|
332
|
+
zipFileSizeInBytes: zipSize,
|
|
333
|
+
buildPayloadSizeInBytes: 0,
|
|
334
|
+
lines: 0,
|
|
335
|
+
};
|
|
336
|
+
const trucation = await csharpDependencyGraph.generateTruncation(path.join(projectPathUri, 'main.cs'));
|
|
337
|
+
assert.deepEqual(trucation, expectedResult);
|
|
338
|
+
});
|
|
339
|
+
});
|
|
340
|
+
});
|
|
341
|
+
//# sourceMappingURL=csharpDependencyGraph.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"csharpDependencyGraph.test.js","sourceRoot":"","sources":["../../../src/language-server/dependencyGraph/csharpDependencyGraph.test.ts"],"names":[],"mappings":";;AAAA,iCAAgC;AAChC,6BAA4B;AAC5B,+BAA8B;AAC9B,mEAA+D;AAE/D,QAAQ,CAAC,4BAA4B,EAAE,GAAG,EAAE;IACxC,IAAI,qBAA4C,CAAA;IAChD,MAAM,wBAAwB,GAAG,KAAK,CAAC,IAAI,EAAE,CAAA;IAC7C,MAAM,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC,CAAA;IACrE,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;IAC1C,MAAM,QAAQ,GAAG;QACb,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE;QAClB,MAA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B,KAAK,EAAE,CAAC;aACX,CAAA;YAED,MAAM,SAAS,GAAG,MAAM,qBAAqB,CAAC,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,SAAS,CAAC,CAAC,CAAA;YAEtG,MAAM,CAAC,SAAS,CAAC,SAAS,EAAE,cAAc,CAAC,CAAA;QAC/C,CAAC,CAAC,CAAA;IACN,CAAC,CAAC,CAAA;AACN,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Workspace } from '@aws/language-server-runtimes/out/features';
|
|
3
|
+
export interface Truncation {
|
|
4
|
+
rootDir: string;
|
|
5
|
+
zipFileBuffer: Buffer;
|
|
6
|
+
scannedFiles: Set<string>;
|
|
7
|
+
srcPayloadSizeInBytes: number;
|
|
8
|
+
buildPayloadSizeInBytes: number;
|
|
9
|
+
zipFileSizeInBytes: number;
|
|
10
|
+
lines: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Create a dependency graph to select all the dependent files associated with current active file.
|
|
14
|
+
* @param uri
|
|
15
|
+
* @returns
|
|
16
|
+
*/
|
|
17
|
+
export declare abstract class DependencyGraph {
|
|
18
|
+
workspace: Workspace;
|
|
19
|
+
protected _sysPaths: Set<string>;
|
|
20
|
+
protected _parsedStatements: Set<string>;
|
|
21
|
+
protected _pickedSourceFiles: Set<string>;
|
|
22
|
+
protected _fetchedDirs: Set<string>;
|
|
23
|
+
protected _totalSize: number;
|
|
24
|
+
protected _tmpDir: string;
|
|
25
|
+
protected _truncDir: string;
|
|
26
|
+
protected _totalLines: number;
|
|
27
|
+
private _isProjectTruncated;
|
|
28
|
+
constructor(workspace: Workspace);
|
|
29
|
+
/**
|
|
30
|
+
* Retrun project name if given uri is within project. If not then return last folder name where file is present.
|
|
31
|
+
* @param uri file path to get project name
|
|
32
|
+
* @returns project folder name
|
|
33
|
+
*/
|
|
34
|
+
getProjectName(uri: string): Promise<string>;
|
|
35
|
+
/**
|
|
36
|
+
* Retrun project path if given uri is within project. If not then return current directory path where file is present.
|
|
37
|
+
* @param uri file path to get project path
|
|
38
|
+
* @returns project path uri if found within workspace otherwise current directory path of input uri
|
|
39
|
+
*/
|
|
40
|
+
getProjectPath(uri: string): Promise<string>;
|
|
41
|
+
/**
|
|
42
|
+
* Retrun readable size limit value in MB or KB
|
|
43
|
+
*/
|
|
44
|
+
getReadableSizeLimit(): string;
|
|
45
|
+
/**
|
|
46
|
+
* checks if the given size value exceeds the payload size limit or not
|
|
47
|
+
*/
|
|
48
|
+
exceedsSizeLimit(size: number): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* get value of _isProjectTruncated
|
|
51
|
+
*/
|
|
52
|
+
get isProjectTruncated(): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* set value for _isProjectTruncated
|
|
55
|
+
*/
|
|
56
|
+
set isProjectTruncated(value: boolean);
|
|
57
|
+
/**
|
|
58
|
+
* copy list of file to temp dir
|
|
59
|
+
*/
|
|
60
|
+
protected copyFilesToTmpDir(files: Set<string> | string[], dir: string): Promise<void>;
|
|
61
|
+
/**
|
|
62
|
+
* copy input file in temp dir (destDir) with same relative path of srcFile in destDir.
|
|
63
|
+
* @param srcFilePath file path to be copied
|
|
64
|
+
* @param destDir destination directory path
|
|
65
|
+
*/
|
|
66
|
+
protected copyFileToTmp(srcFilePath: string, destDir: string): Promise<void>;
|
|
67
|
+
/**
|
|
68
|
+
* create a zip dir buffer of the given dir.
|
|
69
|
+
* @param dir directory path to create zip of the directory
|
|
70
|
+
* @returns zipped dir buffer object and its size in bytes
|
|
71
|
+
*/
|
|
72
|
+
createZip(dir: string): {
|
|
73
|
+
zipFileBuffer: Buffer;
|
|
74
|
+
zipFileSize: number;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* delete directory along with its sub-directories and files if it exists
|
|
78
|
+
* @param dir directory path to remove
|
|
79
|
+
*/
|
|
80
|
+
protected removeDir(dir: string): Promise<void>;
|
|
81
|
+
/**
|
|
82
|
+
* get or create truncation directory path
|
|
83
|
+
* @returns truncation directory path
|
|
84
|
+
*/
|
|
85
|
+
protected getTruncDirPath(): string;
|
|
86
|
+
/**
|
|
87
|
+
* Get total size of list of files
|
|
88
|
+
* @param files list of file paths to find size
|
|
89
|
+
* @returns total size of the input list of files
|
|
90
|
+
*/
|
|
91
|
+
protected getFilesTotalSize(files: string[]): Promise<number>;
|
|
92
|
+
/**
|
|
93
|
+
* remove all copied files from temp directory
|
|
94
|
+
*/
|
|
95
|
+
protected removeTmpFiles(truncation: Truncation): Promise<void>;
|
|
96
|
+
/**
|
|
97
|
+
* This method will traverse throw the input file and its dependecy files to creates a list of files for the scan.
|
|
98
|
+
* If the list does not exceeds the payload size limit then it will scan all the remaining files to add them into the list
|
|
99
|
+
* until it reaches to the payload size limit. Then, it copies all the selected files to temp directory, creates a zip buffer.
|
|
100
|
+
* @param uri file path for which truncation being created
|
|
101
|
+
* @returns Truncation object
|
|
102
|
+
*/
|
|
103
|
+
abstract generateTruncation(uri: string): Promise<Truncation>;
|
|
104
|
+
/**
|
|
105
|
+
* Search for all the dependecies for the given input file. Store the input filepath along with
|
|
106
|
+
* the dependent filepaths until it does not exceeds the payload size limit.
|
|
107
|
+
* @param uri file path to seach dependency of the file
|
|
108
|
+
* @returns set of file paths found as dependecy of input uri
|
|
109
|
+
*/
|
|
110
|
+
abstract searchDependency(uri: string): Promise<Set<string>>;
|
|
111
|
+
/**
|
|
112
|
+
* Traverse all the Csharp files in the given workspace and add each file along with its dependencies to
|
|
113
|
+
* the list of files selected for security scan.
|
|
114
|
+
*/
|
|
115
|
+
abstract traverseDir(dirPath: string): void;
|
|
116
|
+
/**
|
|
117
|
+
* Create a dependency file path set for given list of namespace.
|
|
118
|
+
* @param imports list of import strings
|
|
119
|
+
*/
|
|
120
|
+
abstract getDependencies(imports: string[]): void;
|
|
121
|
+
/**
|
|
122
|
+
* Get payload size limit in bytes for the given Language.
|
|
123
|
+
*/
|
|
124
|
+
abstract getPayloadSizeLimitInBytes(): number;
|
|
125
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DependencyGraph = void 0;
|
|
4
|
+
const admZip = require("adm-zip");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
const CodeWhispererConstants = require("./constants");
|
|
7
|
+
/**
|
|
8
|
+
* Create a dependency graph to select all the dependent files associated with current active file.
|
|
9
|
+
* @param uri
|
|
10
|
+
* @returns
|
|
11
|
+
*/
|
|
12
|
+
class DependencyGraph {
|
|
13
|
+
constructor(workspace) {
|
|
14
|
+
this._sysPaths = new Set();
|
|
15
|
+
this._parsedStatements = new Set();
|
|
16
|
+
this._pickedSourceFiles = new Set();
|
|
17
|
+
this._fetchedDirs = new Set();
|
|
18
|
+
this._totalSize = 0;
|
|
19
|
+
this._tmpDir = '';
|
|
20
|
+
this._truncDir = '';
|
|
21
|
+
this._totalLines = 0;
|
|
22
|
+
this._isProjectTruncated = false;
|
|
23
|
+
this.workspace = workspace;
|
|
24
|
+
this._tmpDir = this.workspace.fs.getTempDirPath();
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Retrun project name if given uri is within project. If not then return last folder name where file is present.
|
|
28
|
+
* @param uri file path to get project name
|
|
29
|
+
* @returns project folder name
|
|
30
|
+
*/
|
|
31
|
+
async getProjectName(uri) {
|
|
32
|
+
const projectPath = await this.getProjectPath(uri);
|
|
33
|
+
return path.basename(projectPath);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Retrun project path if given uri is within project. If not then return current directory path where file is present.
|
|
37
|
+
* @param uri file path to get project path
|
|
38
|
+
* @returns project path uri if found within workspace otherwise current directory path of input uri
|
|
39
|
+
*/
|
|
40
|
+
async getProjectPath(uri) {
|
|
41
|
+
const workspaceFolder = this.workspace.getWorkspaceFolder(uri);
|
|
42
|
+
if (!workspaceFolder) {
|
|
43
|
+
return (await this.workspace.fs.isFile(uri)) ? path.dirname(uri) : uri;
|
|
44
|
+
}
|
|
45
|
+
return workspaceFolder.uri;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Retrun readable size limit value in MB or KB
|
|
49
|
+
*/
|
|
50
|
+
getReadableSizeLimit() {
|
|
51
|
+
const totalBytesInMB = Math.pow(2, 20);
|
|
52
|
+
const totalBytesInKB = Math.pow(2, 10);
|
|
53
|
+
if (this.getPayloadSizeLimitInBytes() >= totalBytesInMB) {
|
|
54
|
+
return `${this.getPayloadSizeLimitInBytes() / totalBytesInMB}MB`;
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
return `${this.getPayloadSizeLimitInBytes() / totalBytesInKB}KB`;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* checks if the given size value exceeds the payload size limit or not
|
|
62
|
+
*/
|
|
63
|
+
exceedsSizeLimit(size) {
|
|
64
|
+
return size >= this.getPayloadSizeLimitInBytes();
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* get value of _isProjectTruncated
|
|
68
|
+
*/
|
|
69
|
+
get isProjectTruncated() {
|
|
70
|
+
return this._isProjectTruncated;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* set value for _isProjectTruncated
|
|
74
|
+
*/
|
|
75
|
+
set isProjectTruncated(value) {
|
|
76
|
+
this._isProjectTruncated = value;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* copy list of file to temp dir
|
|
80
|
+
*/
|
|
81
|
+
async copyFilesToTmpDir(files, dir) {
|
|
82
|
+
// Convert Set to an array for compatibility with Promise.all
|
|
83
|
+
const fileArray = Array.from(files);
|
|
84
|
+
// Use Promise.all to asynchronously copy all files
|
|
85
|
+
await Promise.all(fileArray.map(async (filePath) => {
|
|
86
|
+
await this.copyFileToTmp(filePath, dir);
|
|
87
|
+
}));
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* copy input file in temp dir (destDir) with same relative path of srcFile in destDir.
|
|
91
|
+
* @param srcFilePath file path to be copied
|
|
92
|
+
* @param destDir destination directory path
|
|
93
|
+
*/
|
|
94
|
+
async copyFileToTmp(srcFilePath, destDir) {
|
|
95
|
+
const sourceWorkspacePath = await this.getProjectPath(srcFilePath);
|
|
96
|
+
const fileRelativePath = path.relative(sourceWorkspacePath, srcFilePath);
|
|
97
|
+
const destinationFileAbsolutePath = path.join(destDir, fileRelativePath);
|
|
98
|
+
await this.workspace.fs.copy(srcFilePath, destinationFileAbsolutePath);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* create a zip dir buffer of the given dir.
|
|
102
|
+
* @param dir directory path to create zip of the directory
|
|
103
|
+
* @returns zipped dir buffer object and its size in bytes
|
|
104
|
+
*/
|
|
105
|
+
createZip(dir) {
|
|
106
|
+
const zip = new admZip();
|
|
107
|
+
zip.addLocalFolder(dir);
|
|
108
|
+
// writeZip uses `fs` under the hood and it wouldn't work in browsers
|
|
109
|
+
// Instead of writeZip to write to disk.
|
|
110
|
+
// The zip buffer can then be uploaded to s3
|
|
111
|
+
const zipBuffer = zip.toBuffer();
|
|
112
|
+
return { zipFileBuffer: zipBuffer, zipFileSize: zipBuffer.byteLength };
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* delete directory along with its sub-directories and files if it exists
|
|
116
|
+
* @param dir directory path to remove
|
|
117
|
+
*/
|
|
118
|
+
async removeDir(dir) {
|
|
119
|
+
if (await this.workspace.fs.exists(dir)) {
|
|
120
|
+
await this.workspace.fs.remove(dir);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* get or create truncation directory path
|
|
125
|
+
* @returns truncation directory path
|
|
126
|
+
*/
|
|
127
|
+
getTruncDirPath() {
|
|
128
|
+
if (this._truncDir === '') {
|
|
129
|
+
this._truncDir = path.join(this._tmpDir, CodeWhispererConstants.codeScanTruncDirPrefix + '_' + Date.now().toString());
|
|
130
|
+
}
|
|
131
|
+
return this._truncDir;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Get total size of list of files
|
|
135
|
+
* @param files list of file paths to find size
|
|
136
|
+
* @returns total size of the input list of files
|
|
137
|
+
*/
|
|
138
|
+
async getFilesTotalSize(files) {
|
|
139
|
+
const fileStatsPromises = files.map(file => this.workspace.fs.getFileSize(file));
|
|
140
|
+
const fileStats = await Promise.all(fileStatsPromises);
|
|
141
|
+
const totalSize = fileStats.reduce((accumulator, { size }) => accumulator + size, 0);
|
|
142
|
+
return totalSize;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* remove all copied files from temp directory
|
|
146
|
+
*/
|
|
147
|
+
async removeTmpFiles(truncation) {
|
|
148
|
+
await this.removeDir(truncation.rootDir);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
exports.DependencyGraph = DependencyGraph;
|
|
152
|
+
//# sourceMappingURL=dependencyGraph.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dependencyGraph.js","sourceRoot":"","sources":["../../../src/language-server/dependencyGraph/dependencyGraph.ts"],"names":[],"mappings":";;;AACA,kCAAiC;AACjC,6BAA4B;AAC5B,sDAAqD;AAYrD;;;;GAIG;AACH,MAAsB,eAAe;IAajC,YAAY,SAAoB;QAXtB,cAAS,GAAgB,IAAI,GAAG,EAAU,CAAA;QAC1C,sBAAiB,GAAgB,IAAI,GAAG,EAAU,CAAA;QAClD,uBAAkB,GAAgB,IAAI,GAAG,EAAU,CAAA;QACnD,iBAAY,GAAgB,IAAI,GAAG,EAAU,CAAA;QAC7C,eAAU,GAAG,CAAC,CAAA;QACd,YAAO,GAAG,EAAE,CAAA;QACZ,cAAS,GAAG,EAAE,CAAA;QACd,gBAAW,GAAG,CAAC,CAAA;QAEjB,wBAAmB,GAAG,KAAK,CAAA;QAG/B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;QAC1B,IAAI,CAAC,O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'@aws/language-server-runtimes/out/features';
|
|
2
|
+
import { TextDocument } from 'vscode-languageserver-textdocument';
|
|
3
|
+
import { CsharpDependencyGraph } from './csharpDependencyGraph';
|
|
4
|
+
declare const languageMap: {
|
|
5
|
+
readonly csharp: typeof CsharpDependencyGraph;
|
|
6
|
+
};
|
|
7
|
+
type LanguageMap = typeof languageMap;
|
|
8
|
+
type Keys = keyof LanguageMap;
|
|
9
|
+
type Tuples<T> = T extends Keys ? [T, InstanceType<LanguageMap[T]>] : never;
|
|
10
|
+
type ClassType<A extends Keys> = Extract<Tuples<Keys>, [A, any]>[1];
|
|
11
|
+
export declare class DependencyGraphFactory {
|
|
12
|
+
static getDependencyGraphFromFileExtensions<K extends Keys>(fileName: string): ClassType<K>;
|
|
13
|
+
static getDependencyGraph<K extends Keys>(document: TextDocument, workspace: Required<Workspace>): ClassType<K>;
|
|
14
|
+
}
|
|
15
|
+
export {};
|