Add files using upload-large-folder tool
Browse files- local-test-zookeeper-delta-01/fuzz-tooling/infra/ci/requirements.txt +9 -0
- local-test-zookeeper-delta-01/fuzz-tooling/infra/uploader/Dockerfile +7 -0
- local-test-zookeeper-delta-01/fuzz-tooling/tools/vscode-extension/src/commands/cmdBuildFuzzerFromWorkspace.ts +80 -0
- local-test-zookeeper-delta-01/fuzz-tooling/tools/vscode-extension/src/commands/cmdBuildFuzzerFromWorkspaceCFLite.ts +49 -0
- local-test-zookeeper-delta-01/fuzz-tooling/tools/vscode-extension/src/commands/cmdCreateOSSFuzzSetup.ts +28 -0
- local-test-zookeeper-delta-01/fuzz-tooling/tools/vscode-extension/src/commands/cmdDispatcherGenerateClusterfuzzLite.ts +38 -0
- local-test-zookeeper-delta-01/fuzz-tooling/tools/vscode-extension/src/commands/cmdDisplayCoverage.ts +71 -0
- local-test-zookeeper-delta-01/fuzz-tooling/tools/vscode-extension/src/commands/cmdEndToEndCoverage.ts +192 -0
- local-test-zookeeper-delta-01/fuzz-tooling/tools/vscode-extension/src/commands/cmdFIGetOptimalTargets.ts +21 -0
- local-test-zookeeper-delta-01/fuzz-tooling/tools/vscode-extension/src/commands/cmdListFuzzers.ts +42 -0
- local-test-zookeeper-delta-01/fuzz-tooling/tools/vscode-extension/src/commands/cmdRedo.ts +35 -0
- local-test-zookeeper-delta-01/fuzz-tooling/tools/vscode-extension/src/commands/cmdRunFI.ts +24 -0
- local-test-zookeeper-delta-01/fuzz-tooling/tools/vscode-extension/src/commands/cmdRunFuzzer.ts +83 -0
- local-test-zookeeper-delta-01/fuzz-tooling/tools/vscode-extension/src/commands/cmdSetOSSFuzzPath.ts +59 -0
- local-test-zookeeper-delta-01/fuzz-tooling/tools/vscode-extension/src/commands/cmdSetupCIFuzz.ts +87 -0
- local-test-zookeeper-delta-01/fuzz-tooling/tools/vscode-extension/src/commands/cmdSetupFI.ts +24 -0
- local-test-zookeeper-delta-01/fuzz-tooling/tools/vscode-extension/src/commands/cmdSetupOSSFuzz.ts +53 -0
- local-test-zookeeper-delta-01/fuzz-tooling/tools/vscode-extension/src/commands/cmdTestFuzzer.ts +90 -0
- local-test-zookeeper-delta-01/fuzz-tooling/tools/vscode-extension/src/commands/cmdTestFuzzerCFLite.ts +89 -0
- local-test-zookeeper-delta-01/fuzz-tooling/tools/vscode-extension/src/fuzzIntrospectorHelper.ts +117 -0
local-test-zookeeper-delta-01/fuzz-tooling/infra/ci/requirements.txt
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Requirements for submitting code changes to infra/ (needed by presubmit.py).
|
| 2 |
+
parameterized==0.7.4
|
| 3 |
+
pyfakefs==4.5.6
|
| 4 |
+
pylint==2.5.3
|
| 5 |
+
pytest==7.1.2
|
| 6 |
+
pytest-xdist==2.5.0
|
| 7 |
+
PyYAML==6.0
|
| 8 |
+
requests==2.31.0
|
| 9 |
+
yapf==0.32.0
|
local-test-zookeeper-delta-01/fuzz-tooling/infra/uploader/Dockerfile
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from ubuntu:16.04
|
| 2 |
+
|
| 3 |
+
RUN apt-get update && apt-get upgrade -y
|
| 4 |
+
RUN apt-get install -y curl
|
| 5 |
+
|
| 6 |
+
ENTRYPOINT ["curl", "--retry", "5", "-X", "PUT", "-T"]
|
| 7 |
+
|
local-test-zookeeper-delta-01/fuzz-tooling/tools/vscode-extension/src/commands/cmdBuildFuzzerFromWorkspace.ts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Copyright 2023 Google LLC
|
| 2 |
+
//
|
| 3 |
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
// you may not use this file except in compliance with the License.
|
| 5 |
+
// You may obtain a copy of the License at
|
| 6 |
+
//
|
| 7 |
+
// http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
//
|
| 9 |
+
// Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
// See the License for the specific language governing permissions and
|
| 13 |
+
// limitations under the License.
|
| 14 |
+
//
|
| 15 |
+
////////////////////////////////////////////////////////////////////////////////
|
| 16 |
+
|
| 17 |
+
import * as vscode from 'vscode';
|
| 18 |
+
import {println} from '../logger';
|
| 19 |
+
import {commandHistory} from '../commandUtils';
|
| 20 |
+
import {
|
| 21 |
+
hasOssFuzzInWorkspace,
|
| 22 |
+
getOssFuzzWorkspaceProjectName,
|
| 23 |
+
setStatusText,
|
| 24 |
+
} from '../utils';
|
| 25 |
+
import {buildFuzzersFromWorkspace} from '../ossfuzzWrappers';
|
| 26 |
+
|
| 27 |
+
export async function cmdInputCollectorBuildFuzzersFromWorkspace() {
|
| 28 |
+
let ossFuzzProjectName = '';
|
| 29 |
+
// First determine if we have a name in the workspace
|
| 30 |
+
if (await hasOssFuzzInWorkspace()) {
|
| 31 |
+
/**
|
| 32 |
+
* The fuzzers are in the workspace, as opposed to e.g. the oss-fuzz dirctory.
|
| 33 |
+
*/
|
| 34 |
+
ossFuzzProjectName = await getOssFuzzWorkspaceProjectName();
|
| 35 |
+
} else {
|
| 36 |
+
// If we did not have that, ask the user.
|
| 37 |
+
|
| 38 |
+
const ossFuzzProjectNameInput = await vscode.window.showInputBox({
|
| 39 |
+
value: '',
|
| 40 |
+
placeHolder: 'The OSS-Fuzz project name',
|
| 41 |
+
});
|
| 42 |
+
if (!ossFuzzProjectNameInput) {
|
| 43 |
+
println('Did not get a ossFuzzTargetProject');
|
| 44 |
+
return false;
|
| 45 |
+
}
|
| 46 |
+
ossFuzzProjectName = ossFuzzProjectNameInput.toString();
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
// Create an history object
|
| 50 |
+
const args = new Object({
|
| 51 |
+
projectName: ossFuzzProjectName,
|
| 52 |
+
sanitizer: '',
|
| 53 |
+
toClean: false,
|
| 54 |
+
});
|
| 55 |
+
|
| 56 |
+
const commandObject = new Object({
|
| 57 |
+
commandType: 'oss-fuzz.WSBuildFuzzers',
|
| 58 |
+
Arguments: args,
|
| 59 |
+
dispatcherFunc: cmdDispatchBuildFuzzersFromWorkspace,
|
| 60 |
+
});
|
| 61 |
+
console.log('L1: ' + commandHistory.length);
|
| 62 |
+
commandHistory.push(commandObject);
|
| 63 |
+
|
| 64 |
+
await cmdDispatchBuildFuzzersFromWorkspace(args);
|
| 65 |
+
return true;
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
async function cmdDispatchBuildFuzzersFromWorkspace(args: any) {
|
| 69 |
+
await setStatusText('Building fuzzers: starting');
|
| 70 |
+
const res = await buildFuzzersFromWorkspace(
|
| 71 |
+
args.projectName,
|
| 72 |
+
args.sanitizer,
|
| 73 |
+
args.toClean
|
| 74 |
+
);
|
| 75 |
+
if (res) {
|
| 76 |
+
await setStatusText('Building fuzzers: finished');
|
| 77 |
+
} else {
|
| 78 |
+
await setStatusText('Building fuzzers: failed');
|
| 79 |
+
}
|
| 80 |
+
}
|
local-test-zookeeper-delta-01/fuzz-tooling/tools/vscode-extension/src/commands/cmdBuildFuzzerFromWorkspaceCFLite.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
| 2 |
+
// Copyright 2023 Google LLC
|
| 3 |
+
//
|
| 4 |
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
// you may not use this file except in compliance with the License.
|
| 6 |
+
// You may obtain a copy of the License at
|
| 7 |
+
//
|
| 8 |
+
// http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
//
|
| 10 |
+
// Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
// See the License for the specific language governing permissions and
|
| 14 |
+
// limitations under the License.
|
| 15 |
+
//
|
| 16 |
+
////////////////////////////////////////////////////////////////////////////////
|
| 17 |
+
|
| 18 |
+
import {commandHistory} from '../commandUtils';
|
| 19 |
+
import {setStatusText} from '../utils';
|
| 20 |
+
import {buildFuzzersFromWorkspaceClusterfuzzLite} from '../ossfuzzWrappers';
|
| 21 |
+
|
| 22 |
+
export async function cmdInputCollectorBuildFuzzersFromWorkspaceCFLite() {
|
| 23 |
+
// Create an history object
|
| 24 |
+
const args = new Object({
|
| 25 |
+
toClean: false,
|
| 26 |
+
});
|
| 27 |
+
|
| 28 |
+
const commandObject = new Object({
|
| 29 |
+
commandType: 'oss-fuzz.WSBuildFuzzers',
|
| 30 |
+
Arguments: args,
|
| 31 |
+
dispatcherFunc: cmdDispatchbuildFuzzersFromWorkspaceClusterfuzzLite,
|
| 32 |
+
});
|
| 33 |
+
console.log('L1: ' + commandHistory.length);
|
| 34 |
+
commandHistory.push(commandObject);
|
| 35 |
+
|
| 36 |
+
await cmdDispatchbuildFuzzersFromWorkspaceClusterfuzzLite(args);
|
| 37 |
+
return true;
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
| 41 |
+
async function cmdDispatchbuildFuzzersFromWorkspaceClusterfuzzLite(_args: any) {
|
| 42 |
+
await setStatusText('[CFLite] Building fuzzers: starting');
|
| 43 |
+
const res = await buildFuzzersFromWorkspaceClusterfuzzLite();
|
| 44 |
+
if (res) {
|
| 45 |
+
await setStatusText('[CFLite] Building fuzzers: finished');
|
| 46 |
+
} else {
|
| 47 |
+
await setStatusText('[CFLite] Building fuzzers: failed');
|
| 48 |
+
}
|
| 49 |
+
}
|
local-test-zookeeper-delta-01/fuzz-tooling/tools/vscode-extension/src/commands/cmdCreateOSSFuzzSetup.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Copyright 2023 Google LLC
|
| 2 |
+
//
|
| 3 |
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
// you may not use this file except in compliance with the License.
|
| 5 |
+
// You may obtain a copy of the License at
|
| 6 |
+
//
|
| 7 |
+
// http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
//
|
| 9 |
+
// Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
// See the License for the specific language governing permissions and
|
| 13 |
+
// limitations under the License.
|
| 14 |
+
//
|
| 15 |
+
////////////////////////////////////////////////////////////////////////////////
|
| 16 |
+
|
| 17 |
+
import {setupProjectInitialFiles} from '../projectIntegrationHelper';
|
| 18 |
+
import {setStatusText} from '../utils';
|
| 19 |
+
|
| 20 |
+
export async function createOssFuzzSetup() {
|
| 21 |
+
await setStatusText('Creating OSS-Fuzz setup: starting');
|
| 22 |
+
const res = await setupProjectInitialFiles(false);
|
| 23 |
+
if (res) {
|
| 24 |
+
await setStatusText('Creating OSS-Fuzz setup: finished');
|
| 25 |
+
} else {
|
| 26 |
+
await setStatusText('Creating OSS-Fuzz setup: failed');
|
| 27 |
+
}
|
| 28 |
+
}
|
local-test-zookeeper-delta-01/fuzz-tooling/tools/vscode-extension/src/commands/cmdDispatcherGenerateClusterfuzzLite.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Copyright 2023 Google LLC
|
| 2 |
+
//
|
| 3 |
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
// you may not use this file except in compliance with the License.
|
| 5 |
+
// You may obtain a copy of the License at
|
| 6 |
+
//
|
| 7 |
+
// http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
//
|
| 9 |
+
// Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
// See the License for the specific language governing permissions and
|
| 13 |
+
// limitations under the License.
|
| 14 |
+
//
|
| 15 |
+
////////////////////////////////////////////////////////////////////////////////
|
| 16 |
+
|
| 17 |
+
/**
|
| 18 |
+
* Command for generating template fuzzers. This is a short-cut for rapid
|
| 19 |
+
* prototyping as well as an archive for inspiration.
|
| 20 |
+
*/
|
| 21 |
+
import * as vscode from 'vscode';
|
| 22 |
+
import {setStatusText} from '../utils';
|
| 23 |
+
|
| 24 |
+
import {setupProjectInitialFiles} from '../projectIntegrationHelper';
|
| 25 |
+
|
| 26 |
+
export async function cmdDispatcherGenerateClusterfuzzLite(
|
| 27 |
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
| 28 |
+
_context: vscode.ExtensionContext
|
| 29 |
+
) {
|
| 30 |
+
await setStatusText('Creating OSS-Fuzz setup: starting');
|
| 31 |
+
const res = await setupProjectInitialFiles(true);
|
| 32 |
+
if (res) {
|
| 33 |
+
await setStatusText('Creating OSS-Fuzz setup: finished');
|
| 34 |
+
} else {
|
| 35 |
+
await setStatusText('Creating OSS-Fuzz setup: failed');
|
| 36 |
+
}
|
| 37 |
+
return;
|
| 38 |
+
}
|
local-test-zookeeper-delta-01/fuzz-tooling/tools/vscode-extension/src/commands/cmdDisplayCoverage.ts
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Copyright 2023 Google LLC
|
| 2 |
+
//
|
| 3 |
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
// you may not use this file except in compliance with the License.
|
| 5 |
+
// You may obtain a copy of the License at
|
| 6 |
+
//
|
| 7 |
+
// http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
//
|
| 9 |
+
// Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
// See the License for the specific language governing permissions and
|
| 13 |
+
// limitations under the License.
|
| 14 |
+
//
|
| 15 |
+
////////////////////////////////////////////////////////////////////////////////
|
| 16 |
+
|
| 17 |
+
import * as vscode from 'vscode';
|
| 18 |
+
import {loadCoverageIntoWorkspace} from '../coverageHelper';
|
| 19 |
+
import {println} from '../logger';
|
| 20 |
+
import {getApi, FileDownloader} from '@microsoft/vscode-file-downloader-api';
|
| 21 |
+
|
| 22 |
+
/*
|
| 23 |
+
* Displays code coverage from OSS-Fuzz.
|
| 24 |
+
*
|
| 25 |
+
* Downloads a code coverage report from the OSS-Fuzz online storage, and then overlays
|
| 26 |
+
* the relevant source files with the coverage information.
|
| 27 |
+
*/
|
| 28 |
+
export async function displayCodeCoverageFromOssFuzz(
|
| 29 |
+
context: vscode.ExtensionContext
|
| 30 |
+
) {
|
| 31 |
+
const projectName = await vscode.window.showInputBox({
|
| 32 |
+
value: '',
|
| 33 |
+
placeHolder: "The project you'd like to get code coverage for.",
|
| 34 |
+
});
|
| 35 |
+
if (!projectName) {
|
| 36 |
+
return;
|
| 37 |
+
}
|
| 38 |
+
println('Getting code coverage for ' + projectName);
|
| 39 |
+
|
| 40 |
+
const fileDownloader: FileDownloader = await getApi();
|
| 41 |
+
|
| 42 |
+
const currentDate = new Date();
|
| 43 |
+
const yesterday = new Date(currentDate);
|
| 44 |
+
yesterday.setDate(yesterday.getDate() - 1);
|
| 45 |
+
|
| 46 |
+
const day = yesterday.getDate();
|
| 47 |
+
const month = yesterday.getMonth();
|
| 48 |
+
const year = yesterday.getFullYear();
|
| 49 |
+
|
| 50 |
+
try {
|
| 51 |
+
const codeCoverageFile: vscode.Uri = await fileDownloader.downloadFile(
|
| 52 |
+
vscode.Uri.parse(
|
| 53 |
+
'https://storage.googleapis.com/oss-fuzz-coverage/' +
|
| 54 |
+
projectName +
|
| 55 |
+
'/textcov_reports/' +
|
| 56 |
+
year.toString() +
|
| 57 |
+
month.toString() +
|
| 58 |
+
day.toString() +
|
| 59 |
+
'/all_cov.json'
|
| 60 |
+
),
|
| 61 |
+
'all_cov.json',
|
| 62 |
+
context
|
| 63 |
+
);
|
| 64 |
+
await loadCoverageIntoWorkspace(context, codeCoverageFile);
|
| 65 |
+
} catch (err) {
|
| 66 |
+
println(
|
| 67 |
+
'Could not get the URL. Currently, this feature is only supported for Python projects'
|
| 68 |
+
);
|
| 69 |
+
return;
|
| 70 |
+
}
|
| 71 |
+
}
|
local-test-zookeeper-delta-01/fuzz-tooling/tools/vscode-extension/src/commands/cmdEndToEndCoverage.ts
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Copyright 2023 Google LLC
|
| 2 |
+
//
|
| 3 |
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
// you may not use this file except in compliance with the License.
|
| 5 |
+
// You may obtain a copy of the License at
|
| 6 |
+
//
|
| 7 |
+
// http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
//
|
| 9 |
+
// Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
// See the License for the specific language governing permissions and
|
| 13 |
+
// limitations under the License.
|
| 14 |
+
//
|
| 15 |
+
////////////////////////////////////////////////////////////////////////////////
|
| 16 |
+
|
| 17 |
+
import * as vscode from 'vscode';
|
| 18 |
+
const fs = require('fs');
|
| 19 |
+
import {println} from '../logger';
|
| 20 |
+
import {commandHistory} from '../commandUtils';
|
| 21 |
+
import {buildFuzzersFromWorkspace, runFuzzerHandler} from '../ossfuzzWrappers';
|
| 22 |
+
import {listFuzzersForProject, systemSync, setStatusText} from '../utils';
|
| 23 |
+
import {
|
| 24 |
+
compareLocalToRemoteCoverage,
|
| 25 |
+
loadCoverageIntoWorkspace,
|
| 26 |
+
} from '../coverageHelper';
|
| 27 |
+
import {extensionConfig} from '../config';
|
| 28 |
+
|
| 29 |
+
/**
|
| 30 |
+
* Performs the activities:
|
| 31 |
+
* 1) Build a project using address sanitizer
|
| 32 |
+
* 2) Run each fuzzer of the project, saving corpus
|
| 33 |
+
* 3) Build project using coverage sanitizer
|
| 34 |
+
* 4) Collect coverage
|
| 35 |
+
* @param context
|
| 36 |
+
* @returns
|
| 37 |
+
*/
|
| 38 |
+
export async function runEndToEndAndGetCoverage(
|
| 39 |
+
context: vscode.ExtensionContext
|
| 40 |
+
) {
|
| 41 |
+
println('Getting code coverage');
|
| 42 |
+
await setStatusText('end-to-end coverage: getting input');
|
| 43 |
+
const ossFuzzProjectNameInput = await vscode.window.showInputBox({
|
| 44 |
+
value: '',
|
| 45 |
+
placeHolder: 'The OSS-Fuzz project name',
|
| 46 |
+
});
|
| 47 |
+
if (!ossFuzzProjectNameInput) {
|
| 48 |
+
println('Did not get a ossFuzzTargetProject');
|
| 49 |
+
return;
|
| 50 |
+
}
|
| 51 |
+
const secondsToRunEachFuzzer = await vscode.window.showInputBox({
|
| 52 |
+
value: '',
|
| 53 |
+
placeHolder: 'Seconds to run each fuzzer',
|
| 54 |
+
});
|
| 55 |
+
if (!secondsToRunEachFuzzer) {
|
| 56 |
+
println('Did not get number of seconds to run each fuzzer');
|
| 57 |
+
return;
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
// Create an history object
|
| 61 |
+
const args = new Object({
|
| 62 |
+
projectName: ossFuzzProjectNameInput.toString(),
|
| 63 |
+
secondsToRun: secondsToRunEachFuzzer.toString(),
|
| 64 |
+
vsContext: context,
|
| 65 |
+
});
|
| 66 |
+
|
| 67 |
+
const commandObject = new Object({
|
| 68 |
+
commandType: 'oss-fuzz.cmdDispatchEndToEndRun',
|
| 69 |
+
Arguments: args,
|
| 70 |
+
dispatcherFunc: cmdDispatchEndToEndRun,
|
| 71 |
+
});
|
| 72 |
+
console.log('L1: ' + commandHistory.length);
|
| 73 |
+
commandHistory.push(commandObject);
|
| 74 |
+
|
| 75 |
+
await cmdDispatchEndToEndRun(args);
|
| 76 |
+
return;
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
async function cmdDispatchEndToEndRun(args: any) {
|
| 80 |
+
await setStatusText('end-to-end coverage: starting');
|
| 81 |
+
const res = await endToEndRun(
|
| 82 |
+
args.projectName,
|
| 83 |
+
args.secondsToRun,
|
| 84 |
+
args.vsContext
|
| 85 |
+
);
|
| 86 |
+
if (res) {
|
| 87 |
+
await setStatusText('end-to-end coverage: finished succesfully');
|
| 88 |
+
} else {
|
| 89 |
+
await setStatusText('end-to-end coverage: failed');
|
| 90 |
+
}
|
| 91 |
+
return;
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
async function endToEndRun(
|
| 95 |
+
ossFuzzProjectNameInput: string,
|
| 96 |
+
secondsToRunEachFuzzer: string,
|
| 97 |
+
context: vscode.ExtensionContext
|
| 98 |
+
) {
|
| 99 |
+
await setStatusText('end-to-end coverage: build with ASAN');
|
| 100 |
+
vscode.window.showInformationMessage(
|
| 101 |
+
'Building project: ' + ossFuzzProjectNameInput.toString()
|
| 102 |
+
);
|
| 103 |
+
if (
|
| 104 |
+
(await buildFuzzersFromWorkspace(
|
| 105 |
+
ossFuzzProjectNameInput.toString(),
|
| 106 |
+
'',
|
| 107 |
+
true
|
| 108 |
+
)) === false
|
| 109 |
+
) {
|
| 110 |
+
println('Failed to build project');
|
| 111 |
+
return false;
|
| 112 |
+
}
|
| 113 |
+
println('Build projects');
|
| 114 |
+
|
| 115 |
+
// List all of the fuzzers in the project
|
| 116 |
+
const fuzzersInProject = await listFuzzersForProject(
|
| 117 |
+
ossFuzzProjectNameInput,
|
| 118 |
+
extensionConfig.ossFuzzPepositoryWorkPath
|
| 119 |
+
);
|
| 120 |
+
|
| 121 |
+
// Run all of the fuzzers in the project
|
| 122 |
+
await setStatusText('end-to-end coverage: collecting corpus');
|
| 123 |
+
println('Fuzzers found in project: ' + fuzzersInProject.toString());
|
| 124 |
+
println('Running each of the fuzzers to collect a corpus');
|
| 125 |
+
for (const fuzzName of fuzzersInProject) {
|
| 126 |
+
println('Running fuzzer: ' + fuzzName);
|
| 127 |
+
await setStatusText('end-to-end coverage: collecting corpus: ' + fuzzName);
|
| 128 |
+
// Corpus directory
|
| 129 |
+
const fuzzerCorpusPath =
|
| 130 |
+
extensionConfig.ossFuzzPepositoryWorkPath +
|
| 131 |
+
'/build/corpus/' +
|
| 132 |
+
ossFuzzProjectNameInput +
|
| 133 |
+
'/' +
|
| 134 |
+
fuzzName;
|
| 135 |
+
|
| 136 |
+
await systemSync('mkdir', ['-p', fuzzerCorpusPath]);
|
| 137 |
+
|
| 138 |
+
await runFuzzerHandler(
|
| 139 |
+
ossFuzzProjectNameInput,
|
| 140 |
+
fuzzName,
|
| 141 |
+
secondsToRunEachFuzzer.toString(),
|
| 142 |
+
fuzzerCorpusPath
|
| 143 |
+
);
|
| 144 |
+
}
|
| 145 |
+
|
| 146 |
+
// Build with code coverage
|
| 147 |
+
println('Building project with coverage sanitizer');
|
| 148 |
+
await setStatusText('end-to-end coverage: building with coverage');
|
| 149 |
+
await buildFuzzersFromWorkspace(
|
| 150 |
+
ossFuzzProjectNameInput.toString(),
|
| 151 |
+
'coverage',
|
| 152 |
+
true
|
| 153 |
+
);
|
| 154 |
+
|
| 155 |
+
// Run coverage command
|
| 156 |
+
println('Collecting code coverage');
|
| 157 |
+
await setStatusText('end-to-end coverage: collecting coverage');
|
| 158 |
+
const args: Array<string> = [
|
| 159 |
+
extensionConfig.ossFuzzPepositoryWorkPath + '/infra/helper.py',
|
| 160 |
+
'coverage',
|
| 161 |
+
'--port',
|
| 162 |
+
'',
|
| 163 |
+
'--no-corpus-download',
|
| 164 |
+
ossFuzzProjectNameInput.toString(),
|
| 165 |
+
];
|
| 166 |
+
await systemSync('python3', args);
|
| 167 |
+
await setStatusText('end-to-end coverage: finished collecting coverage');
|
| 168 |
+
println('Load coverage report with the command:');
|
| 169 |
+
println(
|
| 170 |
+
'python3 -m http.server 8008 --directory /tmp/oss-fuzz/build/out/' +
|
| 171 |
+
ossFuzzProjectNameInput.toString() +
|
| 172 |
+
'/report/'
|
| 173 |
+
);
|
| 174 |
+
|
| 175 |
+
println('Trying to load code coverage in IDE');
|
| 176 |
+
const allCovPath =
|
| 177 |
+
extensionConfig.ossFuzzPepositoryWorkPath +
|
| 178 |
+
'/build/out/' +
|
| 179 |
+
ossFuzzProjectNameInput.toString() +
|
| 180 |
+
'/textcov_reports/all_cov.json';
|
| 181 |
+
if (fs.existsSync(allCovPath)) {
|
| 182 |
+
const generatedCodeCoverageFile = vscode.Uri.file(allCovPath);
|
| 183 |
+
await loadCoverageIntoWorkspace(context, generatedCodeCoverageFile);
|
| 184 |
+
}
|
| 185 |
+
|
| 186 |
+
await compareLocalToRemoteCoverage(
|
| 187 |
+
context,
|
| 188 |
+
ossFuzzProjectNameInput.toString()
|
| 189 |
+
);
|
| 190 |
+
|
| 191 |
+
return true;
|
| 192 |
+
}
|
local-test-zookeeper-delta-01/fuzz-tooling/tools/vscode-extension/src/commands/cmdFIGetOptimalTargets.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Copyright 2025 Google LLC
|
| 2 |
+
//
|
| 3 |
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
// you may not use this file except in compliance with the License.
|
| 5 |
+
// You may obtain a copy of the License at
|
| 6 |
+
//
|
| 7 |
+
// http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
//
|
| 9 |
+
// Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
// See the License for the specific language governing permissions and
|
| 13 |
+
// limitations under the License.
|
| 14 |
+
//
|
| 15 |
+
////////////////////////////////////////////////////////////////////////////////
|
| 16 |
+
|
| 17 |
+
import {getOptimalTargetsFromIntrospector} from '../fuzzIntrospectorHelper';
|
| 18 |
+
|
| 19 |
+
export async function runGetOptimalTargetsHandler() {
|
| 20 |
+
getOptimalTargetsFromIntrospector();
|
| 21 |
+
}
|
local-test-zookeeper-delta-01/fuzz-tooling/tools/vscode-extension/src/commands/cmdListFuzzers.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Copyright 2023 Google LLC
|
| 2 |
+
//
|
| 3 |
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
// you may not use this file except in compliance with the License.
|
| 5 |
+
// You may obtain a copy of the License at
|
| 6 |
+
//
|
| 7 |
+
// http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
//
|
| 9 |
+
// Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
// See the License for the specific language governing permissions and
|
| 13 |
+
// limitations under the License.
|
| 14 |
+
//
|
| 15 |
+
////////////////////////////////////////////////////////////////////////////////
|
| 16 |
+
|
| 17 |
+
import * as vscode from 'vscode';
|
| 18 |
+
|
| 19 |
+
import {listFuzzersForProject} from '../utils';
|
| 20 |
+
import {println} from '../logger';
|
| 21 |
+
import {extensionConfig} from '../config';
|
| 22 |
+
|
| 23 |
+
/**
|
| 24 |
+
* Lists all the fuzzers for a project.
|
| 25 |
+
*/
|
| 26 |
+
export async function listFuzzersHandler() {
|
| 27 |
+
// Lists all of the fuzzers from a project.
|
| 28 |
+
const projectName = await vscode.window.showInputBox({
|
| 29 |
+
value: '',
|
| 30 |
+
placeHolder: 'Type a project name',
|
| 31 |
+
});
|
| 32 |
+
if (!projectName) {
|
| 33 |
+
console.log('Failed to get project name');
|
| 34 |
+
return;
|
| 35 |
+
}
|
| 36 |
+
println('Listing fuzzers for project ' + projectName);
|
| 37 |
+
|
| 38 |
+
await listFuzzersForProject(
|
| 39 |
+
projectName?.toString(),
|
| 40 |
+
extensionConfig.ossFuzzPepositoryWorkPath
|
| 41 |
+
);
|
| 42 |
+
}
|
local-test-zookeeper-delta-01/fuzz-tooling/tools/vscode-extension/src/commands/cmdRedo.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Copyright 2023 Google LLC
|
| 2 |
+
//
|
| 3 |
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
// you may not use this file except in compliance with the License.
|
| 5 |
+
// You may obtain a copy of the License at
|
| 6 |
+
//
|
| 7 |
+
// http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
//
|
| 9 |
+
// Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
// See the License for the specific language governing permissions and
|
| 13 |
+
// limitations under the License.
|
| 14 |
+
//
|
| 15 |
+
////////////////////////////////////////////////////////////////////////////////
|
| 16 |
+
|
| 17 |
+
import {commandHistory} from '../commandUtils';
|
| 18 |
+
|
| 19 |
+
/**
|
| 20 |
+
* Rerun the latest command
|
| 21 |
+
*/
|
| 22 |
+
export async function cmdDispatcherRe() {
|
| 23 |
+
if (commandHistory.length === 0) {
|
| 24 |
+
console.log('command history is empty');
|
| 25 |
+
return false;
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
const commandObj: any = commandHistory[commandHistory.length - 1];
|
| 29 |
+
|
| 30 |
+
console.log('Redoing');
|
| 31 |
+
console.log(commandObj.commandType);
|
| 32 |
+
await commandObj.dispatcherFunc(commandObj.Arguments);
|
| 33 |
+
//await commandObj.dispatcherFunc(commandObj.args);
|
| 34 |
+
return true;
|
| 35 |
+
}
|
local-test-zookeeper-delta-01/fuzz-tooling/tools/vscode-extension/src/commands/cmdRunFI.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Copyright 2024 Google LLC
|
| 2 |
+
//
|
| 3 |
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
// you may not use this file except in compliance with the License.
|
| 5 |
+
// You may obtain a copy of the License at
|
| 6 |
+
//
|
| 7 |
+
// http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
//
|
| 9 |
+
// Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
// See the License for the specific language governing permissions and
|
| 13 |
+
// limitations under the License.
|
| 14 |
+
//
|
| 15 |
+
////////////////////////////////////////////////////////////////////////////////
|
| 16 |
+
|
| 17 |
+
import {runFuzzIntrospector} from '../fuzzIntrospectorHelper';
|
| 18 |
+
|
| 19 |
+
/**
|
| 20 |
+
* Function for setting up Fuzz Introspector by way of a Python virtual env.
|
| 21 |
+
*/
|
| 22 |
+
export async function runFuzzIntrospectorHandler() {
|
| 23 |
+
runFuzzIntrospector();
|
| 24 |
+
}
|
local-test-zookeeper-delta-01/fuzz-tooling/tools/vscode-extension/src/commands/cmdRunFuzzer.ts
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Copyright 2023 Google LLC
|
| 2 |
+
//
|
| 3 |
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
// you may not use this file except in compliance with the License.
|
| 5 |
+
// You may obtain a copy of the License at
|
| 6 |
+
//
|
| 7 |
+
// http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
//
|
| 9 |
+
// Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
// See the License for the specific language governing permissions and
|
| 13 |
+
// limitations under the License.
|
| 14 |
+
//
|
| 15 |
+
////////////////////////////////////////////////////////////////////////////////
|
| 16 |
+
|
| 17 |
+
import * as vscode from 'vscode';
|
| 18 |
+
import {println} from '../logger';
|
| 19 |
+
import {commandHistory} from '../commandUtils';
|
| 20 |
+
import {runFuzzerHandler} from '../ossfuzzWrappers';
|
| 21 |
+
|
| 22 |
+
export async function cmdInputCollectorRunSpecificFuzzer() {
|
| 23 |
+
let projectNameArg = '';
|
| 24 |
+
let fuzzerName = '';
|
| 25 |
+
let secondsToRun = '';
|
| 26 |
+
|
| 27 |
+
// Runs a fuzzer from a given project.
|
| 28 |
+
const projectNameFromPrompt = await vscode.window.showInputBox({
|
| 29 |
+
value: '',
|
| 30 |
+
placeHolder: 'Type a project name',
|
| 31 |
+
});
|
| 32 |
+
if (!projectNameFromPrompt) {
|
| 33 |
+
println('Failed to get project name');
|
| 34 |
+
return;
|
| 35 |
+
}
|
| 36 |
+
projectNameArg = projectNameFromPrompt.toString();
|
| 37 |
+
const fuzzerNameFromPrompt = await vscode.window.showInputBox({
|
| 38 |
+
value: '',
|
| 39 |
+
placeHolder: 'Type a fuzzer name',
|
| 40 |
+
});
|
| 41 |
+
if (!fuzzerNameFromPrompt) {
|
| 42 |
+
println('Failed to get fuzzer name');
|
| 43 |
+
return;
|
| 44 |
+
}
|
| 45 |
+
fuzzerName = fuzzerNameFromPrompt.toString();
|
| 46 |
+
const secondsToRunInp = await vscode.window.showInputBox({
|
| 47 |
+
value: '',
|
| 48 |
+
placeHolder: 'Type the number of seconds to run the fuzzer',
|
| 49 |
+
});
|
| 50 |
+
if (!secondsToRunInp) {
|
| 51 |
+
return;
|
| 52 |
+
}
|
| 53 |
+
secondsToRun = secondsToRunInp.toString();
|
| 54 |
+
|
| 55 |
+
// Create an history object
|
| 56 |
+
const args = new Object({
|
| 57 |
+
projectName: projectNameArg,
|
| 58 |
+
fuzzerName: fuzzerName,
|
| 59 |
+
secondsToRun: secondsToRun,
|
| 60 |
+
fuzzerCorpusPath: '',
|
| 61 |
+
});
|
| 62 |
+
|
| 63 |
+
const commandObject = new Object({
|
| 64 |
+
commandType: 'oss-fuzz.RunFuzzer',
|
| 65 |
+
Arguments: args,
|
| 66 |
+
dispatcherFunc: cmdDispatchRunFuzzerHandler,
|
| 67 |
+
});
|
| 68 |
+
console.log('L1: ' + commandHistory.length);
|
| 69 |
+
commandHistory.push(commandObject);
|
| 70 |
+
|
| 71 |
+
await cmdDispatchRunFuzzerHandler(args);
|
| 72 |
+
return true;
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
async function cmdDispatchRunFuzzerHandler(args: any) {
|
| 76 |
+
await runFuzzerHandler(
|
| 77 |
+
args.projectName,
|
| 78 |
+
args.fuzzerName,
|
| 79 |
+
args.secondsToRun,
|
| 80 |
+
args.fuzzerCorpusPath
|
| 81 |
+
);
|
| 82 |
+
return;
|
| 83 |
+
}
|
local-test-zookeeper-delta-01/fuzz-tooling/tools/vscode-extension/src/commands/cmdSetOSSFuzzPath.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Copyright 2023 Google LLC
|
| 2 |
+
//
|
| 3 |
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
// you may not use this file except in compliance with the License.
|
| 5 |
+
// You may obtain a copy of the License at
|
| 6 |
+
//
|
| 7 |
+
// http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
//
|
| 9 |
+
// Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
// See the License for the specific language governing permissions and
|
| 13 |
+
// limitations under the License.
|
| 14 |
+
//
|
| 15 |
+
////////////////////////////////////////////////////////////////////////////////
|
| 16 |
+
|
| 17 |
+
import * as vscode from 'vscode';
|
| 18 |
+
|
| 19 |
+
import {println} from '../logger';
|
| 20 |
+
import {extensionConfig} from '../config';
|
| 21 |
+
|
| 22 |
+
// Set the oss-fuzz path.
|
| 23 |
+
export async function setOssFuzzPath() {
|
| 24 |
+
println('Setting path');
|
| 25 |
+
const newOssFuzzPath = await vscode.window.showInputBox({
|
| 26 |
+
value: '',
|
| 27 |
+
placeHolder: 'Type path',
|
| 28 |
+
});
|
| 29 |
+
if (!newOssFuzzPath) {
|
| 30 |
+
println('Failed getting path');
|
| 31 |
+
return;
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
const fpathh = vscode.Uri.file(newOssFuzzPath);
|
| 35 |
+
let isValid = false;
|
| 36 |
+
try {
|
| 37 |
+
if (await vscode.workspace.fs.readDirectory(fpathh)) {
|
| 38 |
+
println('Is a directory');
|
| 39 |
+
const helperPathURI = vscode.Uri.file(
|
| 40 |
+
newOssFuzzPath + '/infra/helper.py'
|
| 41 |
+
);
|
| 42 |
+
if (await vscode.workspace.fs.readFile(helperPathURI)) {
|
| 43 |
+
println('Found helper file');
|
| 44 |
+
isValid = true;
|
| 45 |
+
}
|
| 46 |
+
isValid = true;
|
| 47 |
+
} else {
|
| 48 |
+
isValid = false;
|
| 49 |
+
}
|
| 50 |
+
} catch {
|
| 51 |
+
isValid = false;
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
if (isValid) {
|
| 55 |
+
extensionConfig.ossFuzzPepositoryWorkPath = newOssFuzzPath;
|
| 56 |
+
} else {
|
| 57 |
+
println('Not setting OSS-Fuzz path');
|
| 58 |
+
}
|
| 59 |
+
}
|
local-test-zookeeper-delta-01/fuzz-tooling/tools/vscode-extension/src/commands/cmdSetupCIFuzz.ts
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Copyright 2023 Google LLC
|
| 2 |
+
//
|
| 3 |
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
// you may not use this file except in compliance with the License.
|
| 5 |
+
// You may obtain a copy of the License at
|
| 6 |
+
//
|
| 7 |
+
// http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
//
|
| 9 |
+
// Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
// See the License for the specific language governing permissions and
|
| 13 |
+
// limitations under the License.
|
| 14 |
+
//
|
| 15 |
+
////////////////////////////////////////////////////////////////////////////////
|
| 16 |
+
|
| 17 |
+
import * as vscode from 'vscode';
|
| 18 |
+
import {println} from '../logger';
|
| 19 |
+
import {determineWorkspaceLanguage} from '../utils';
|
| 20 |
+
import {cifuzzGenerator} from '../cifuzz';
|
| 21 |
+
|
| 22 |
+
export async function setupCIFuzzHandler() {
|
| 23 |
+
const workspaceFolder = vscode.workspace.workspaceFolders;
|
| 24 |
+
if (!workspaceFolder) {
|
| 25 |
+
return false;
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
const wsPath = workspaceFolder[0].uri.fsPath; // gets the path of the first workspace folder
|
| 29 |
+
|
| 30 |
+
/**
|
| 31 |
+
* Go through GitHub workflows to find potential traces of CIFuzz
|
| 32 |
+
*/
|
| 33 |
+
const githubWorkflowsPath = vscode.Uri.file(wsPath + '/.github/workflows');
|
| 34 |
+
try {
|
| 35 |
+
await vscode.workspace.fs.readDirectory(githubWorkflowsPath);
|
| 36 |
+
} catch {
|
| 37 |
+
println('Did not find a workflows path.');
|
| 38 |
+
return false;
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
for (const [name, type] of await vscode.workspace.fs.readDirectory(
|
| 42 |
+
githubWorkflowsPath
|
| 43 |
+
)) {
|
| 44 |
+
// Skip directories.
|
| 45 |
+
if (type === 2) {
|
| 46 |
+
continue;
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
// Read the files.
|
| 50 |
+
println('Is a file');
|
| 51 |
+
const workflowFile = vscode.Uri.file(wsPath + '/.github/workflows/' + name);
|
| 52 |
+
const doc = await vscode.workspace.openTextDocument(workflowFile);
|
| 53 |
+
if (doc.getText().includes('cifuzz')) {
|
| 54 |
+
println('Found existing CIFuzz, will not continue.');
|
| 55 |
+
return false;
|
| 56 |
+
}
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
println('Did not find CIFuzz, creating one.');
|
| 60 |
+
const projectName = await vscode.window.showInputBox({
|
| 61 |
+
value: '',
|
| 62 |
+
placeHolder: 'OSS-Fuzz project name',
|
| 63 |
+
});
|
| 64 |
+
if (!projectName) {
|
| 65 |
+
println('Failed to get project name');
|
| 66 |
+
return false;
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
/*
|
| 70 |
+
* There is no CIFuzz found, so we create one.
|
| 71 |
+
*/
|
| 72 |
+
// Determine the language of the workspace.
|
| 73 |
+
const targetLanguage = await determineWorkspaceLanguage();
|
| 74 |
+
println('Target language: ' + targetLanguage);
|
| 75 |
+
|
| 76 |
+
// Generate a CIFuzz workflow text.
|
| 77 |
+
const cifuzzWorkflowText = cifuzzGenerator(targetLanguage, projectName, 30);
|
| 78 |
+
|
| 79 |
+
// Create the CIFuzz .yml file and write the contents to it to path
|
| 80 |
+
// .github/workflows/cifuzz.yml
|
| 81 |
+
const cifuzzYml = vscode.Uri.file(wsPath + '/.github/workflows/cifuzz.yml');
|
| 82 |
+
const wsedit = new vscode.WorkspaceEdit();
|
| 83 |
+
wsedit.createFile(cifuzzYml, {ignoreIfExists: true});
|
| 84 |
+
wsedit.insert(cifuzzYml, new vscode.Position(0, 0), cifuzzWorkflowText);
|
| 85 |
+
vscode.workspace.applyEdit(wsedit);
|
| 86 |
+
return true;
|
| 87 |
+
}
|
local-test-zookeeper-delta-01/fuzz-tooling/tools/vscode-extension/src/commands/cmdSetupFI.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Copyright 2024 Google LLC
|
| 2 |
+
//
|
| 3 |
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
// you may not use this file except in compliance with the License.
|
| 5 |
+
// You may obtain a copy of the License at
|
| 6 |
+
//
|
| 7 |
+
// http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
//
|
| 9 |
+
// Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
// See the License for the specific language governing permissions and
|
| 13 |
+
// limitations under the License.
|
| 14 |
+
//
|
| 15 |
+
////////////////////////////////////////////////////////////////////////////////
|
| 16 |
+
|
| 17 |
+
import {setUpFuzzIntrospector} from '../fuzzIntrospectorHelper';
|
| 18 |
+
|
| 19 |
+
/**
|
| 20 |
+
* Function for setting up Fuzz Introspector by way of a Python virtual env.
|
| 21 |
+
*/
|
| 22 |
+
export async function setUpFuzzIntrospectorHandler() {
|
| 23 |
+
setUpFuzzIntrospector();
|
| 24 |
+
}
|
local-test-zookeeper-delta-01/fuzz-tooling/tools/vscode-extension/src/commands/cmdSetupOSSFuzz.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Copyright 2023 Google LLC
|
| 2 |
+
//
|
| 3 |
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
// you may not use this file except in compliance with the License.
|
| 5 |
+
// You may obtain a copy of the License at
|
| 6 |
+
//
|
| 7 |
+
// http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
//
|
| 9 |
+
// Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
// See the License for the specific language governing permissions and
|
| 13 |
+
// limitations under the License.
|
| 14 |
+
//
|
| 15 |
+
////////////////////////////////////////////////////////////////////////////////
|
| 16 |
+
|
| 17 |
+
import {println} from '../logger';
|
| 18 |
+
import {extensionConfig} from '../config';
|
| 19 |
+
import {isPathValidOssFuzzPath} from '../ossfuzzWrappers';
|
| 20 |
+
import {systemSync} from '../utils';
|
| 21 |
+
|
| 22 |
+
/**
|
| 23 |
+
* Function for setting up oss-fuzz. This clones the relevant directory
|
| 24 |
+
* and sets the oss-fuzz variable accordingly.
|
| 25 |
+
*/
|
| 26 |
+
export async function setUpOssFuzzHandler() {
|
| 27 |
+
println('Setting up oss-fuzz in /tmp/');
|
| 28 |
+
|
| 29 |
+
// First check if we already have an OSS-Fuzz path
|
| 30 |
+
const tmpOssFuzzRepositoryPath = '/tmp/oss-fuzz';
|
| 31 |
+
|
| 32 |
+
if ((await isPathValidOssFuzzPath(tmpOssFuzzRepositoryPath)) === true) {
|
| 33 |
+
println('OSS-Fuzz already exists in /tmp/oss-fuzz');
|
| 34 |
+
extensionConfig.ossFuzzPepositoryWorkPath = tmpOssFuzzRepositoryPath;
|
| 35 |
+
return;
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
const cmdToExec = 'git';
|
| 39 |
+
const args: Array<string> = [
|
| 40 |
+
'clone',
|
| 41 |
+
'https://github.com/google/oss-fuzz',
|
| 42 |
+
tmpOssFuzzRepositoryPath,
|
| 43 |
+
];
|
| 44 |
+
const [res, output] = await systemSync(cmdToExec, args);
|
| 45 |
+
if (res === false) {
|
| 46 |
+
println('Failed to clone oss-fuzz');
|
| 47 |
+
println(output);
|
| 48 |
+
return;
|
| 49 |
+
}
|
| 50 |
+
println('Finished cloning oss-fuzz');
|
| 51 |
+
|
| 52 |
+
extensionConfig.ossFuzzPepositoryWorkPath = tmpOssFuzzRepositoryPath;
|
| 53 |
+
}
|
local-test-zookeeper-delta-01/fuzz-tooling/tools/vscode-extension/src/commands/cmdTestFuzzer.ts
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Copyright 2023 Google LLC
|
| 2 |
+
//
|
| 3 |
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
// you may not use this file except in compliance with the License.
|
| 5 |
+
// You may obtain a copy of the License at
|
| 6 |
+
//
|
| 7 |
+
// http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
//
|
| 9 |
+
// Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
// See the License for the specific language governing permissions and
|
| 13 |
+
// limitations under the License.
|
| 14 |
+
//
|
| 15 |
+
////////////////////////////////////////////////////////////////////////////////
|
| 16 |
+
|
| 17 |
+
import * as vscode from 'vscode';
|
| 18 |
+
import {println} from '../logger';
|
| 19 |
+
import {runFuzzerHandler, buildFuzzersFromWorkspace} from '../ossfuzzWrappers';
|
| 20 |
+
import {setStatusText} from '../utils';
|
| 21 |
+
import {commandHistory} from '../commandUtils';
|
| 22 |
+
import {extensionConfig} from '../config';
|
| 23 |
+
|
| 24 |
+
/**
|
| 25 |
+
* Does an end-to-end test of a project/fuzzer. This is done by
|
| 26 |
+
* first building the project and then running the fuzzer.
|
| 27 |
+
* @param context
|
| 28 |
+
* @returns
|
| 29 |
+
*/
|
| 30 |
+
|
| 31 |
+
export async function cmdInputCollectorTestFuzzer() {
|
| 32 |
+
setStatusText('Testing specific fuzzer: getting input');
|
| 33 |
+
// Get the project name and fuzzer name to test.
|
| 34 |
+
const ossFuzzProjectNameInput = await vscode.window.showInputBox({
|
| 35 |
+
value: '',
|
| 36 |
+
placeHolder: 'The OSS-Fuzz project name',
|
| 37 |
+
});
|
| 38 |
+
if (!ossFuzzProjectNameInput) {
|
| 39 |
+
println('Did not get a ossFuzzTargetProject');
|
| 40 |
+
return;
|
| 41 |
+
}
|
| 42 |
+
println('Project name: ' + ossFuzzProjectNameInput);
|
| 43 |
+
|
| 44 |
+
// Get the fuzzer to run
|
| 45 |
+
const fuzzerNameInput = await vscode.window.showInputBox({
|
| 46 |
+
value: '',
|
| 47 |
+
placeHolder: 'Type a fuzzer name',
|
| 48 |
+
});
|
| 49 |
+
if (!fuzzerNameInput) {
|
| 50 |
+
println('Failed to get fuzzer name');
|
| 51 |
+
return;
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
// Create the args object for the dispatcher
|
| 55 |
+
const args = new Object({
|
| 56 |
+
projectName: ossFuzzProjectNameInput.toString(),
|
| 57 |
+
fuzzerName: fuzzerNameInput.toString(),
|
| 58 |
+
});
|
| 59 |
+
|
| 60 |
+
// Create a dispatcher object.
|
| 61 |
+
const commandObject = new Object({
|
| 62 |
+
commandType: 'oss-fuzz.TestFuzzer',
|
| 63 |
+
Arguments: args,
|
| 64 |
+
dispatcherFunc: cmdDispatchTestFuzzerHandler,
|
| 65 |
+
});
|
| 66 |
+
commandHistory.push(commandObject);
|
| 67 |
+
|
| 68 |
+
await cmdDispatchTestFuzzerHandler(args);
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
async function cmdDispatchTestFuzzerHandler(args: any) {
|
| 72 |
+
// Build the project
|
| 73 |
+
setStatusText('Test specific fuzzer: building fuzzers in workspace');
|
| 74 |
+
if (!(await buildFuzzersFromWorkspace(args.projectName, '', false))) {
|
| 75 |
+
println('Build projects');
|
| 76 |
+
return;
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
// Run the fuzzer for 10 seconds
|
| 80 |
+
println('Running fuzzer');
|
| 81 |
+
setStatusText('Test specific fuzzer: running fuzzer ' + args.fuzzerName);
|
| 82 |
+
await runFuzzerHandler(
|
| 83 |
+
args.projectName,
|
| 84 |
+
args.fuzzerName,
|
| 85 |
+
extensionConfig.numberOfSecondsForTestRuns.toString(),
|
| 86 |
+
''
|
| 87 |
+
);
|
| 88 |
+
setStatusText('Test specific fuzzer: test completed of ' + args.fuzzerName);
|
| 89 |
+
return;
|
| 90 |
+
}
|
local-test-zookeeper-delta-01/fuzz-tooling/tools/vscode-extension/src/commands/cmdTestFuzzerCFLite.ts
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Copyright 2023 Google LLC
|
| 2 |
+
//
|
| 3 |
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
// you may not use this file except in compliance with the License.
|
| 5 |
+
// You may obtain a copy of the License at
|
| 6 |
+
//
|
| 7 |
+
// http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
//
|
| 9 |
+
// Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
// See the License for the specific language governing permissions and
|
| 13 |
+
// limitations under the License.
|
| 14 |
+
//
|
| 15 |
+
////////////////////////////////////////////////////////////////////////////////
|
| 16 |
+
|
| 17 |
+
import path = require('path');
|
| 18 |
+
import * as vscode from 'vscode';
|
| 19 |
+
import {println} from '../logger';
|
| 20 |
+
import {
|
| 21 |
+
runFuzzerHandlerCFLite,
|
| 22 |
+
buildFuzzersFromWorkspaceClusterfuzzLite,
|
| 23 |
+
} from '../ossfuzzWrappers';
|
| 24 |
+
import {setStatusText} from '../utils';
|
| 25 |
+
import {commandHistory} from '../commandUtils';
|
| 26 |
+
import {extensionConfig} from '../config';
|
| 27 |
+
|
| 28 |
+
/**
|
| 29 |
+
* Does an end-to-end test of a project/fuzzer. This is done by
|
| 30 |
+
* first building the project and then running the fuzzer.
|
| 31 |
+
* @param context
|
| 32 |
+
* @returns
|
| 33 |
+
*/
|
| 34 |
+
|
| 35 |
+
export async function cmdInputCollectorTestFuzzerCFLite() {
|
| 36 |
+
setStatusText('Testing specific fuzzer: getting input');
|
| 37 |
+
// Get the fuzzer to run
|
| 38 |
+
const fuzzerNameInput = await vscode.window.showInputBox({
|
| 39 |
+
value: '',
|
| 40 |
+
placeHolder: 'Type a fuzzer name',
|
| 41 |
+
});
|
| 42 |
+
if (!fuzzerNameInput) {
|
| 43 |
+
println('Failed to get fuzzer name');
|
| 44 |
+
return;
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
// Create the args object for the dispatcher
|
| 48 |
+
const args = new Object({
|
| 49 |
+
fuzzerName: fuzzerNameInput.toString(),
|
| 50 |
+
});
|
| 51 |
+
|
| 52 |
+
// Create a dispatcher object.
|
| 53 |
+
const commandObject = new Object({
|
| 54 |
+
commandType: 'oss-fuzz.TestFuzzerCFLite',
|
| 55 |
+
Arguments: args,
|
| 56 |
+
dispatcherFunc: cmdDispatchTestFuzzerHandlerCFLite,
|
| 57 |
+
});
|
| 58 |
+
commandHistory.push(commandObject);
|
| 59 |
+
|
| 60 |
+
await cmdDispatchTestFuzzerHandlerCFLite(args);
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
async function cmdDispatchTestFuzzerHandlerCFLite(args: any) {
|
| 64 |
+
// Build the project
|
| 65 |
+
setStatusText('Test specific fuzzer: building fuzzers in workspace');
|
| 66 |
+
if (!(await buildFuzzersFromWorkspaceClusterfuzzLite())) {
|
| 67 |
+
println('Build projects');
|
| 68 |
+
return;
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
const workspaceFolder = vscode.workspace.workspaceFolders;
|
| 72 |
+
if (!workspaceFolder) {
|
| 73 |
+
return;
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
const pathOfLocal = workspaceFolder[0].uri.path;
|
| 77 |
+
println('path of local: ' + pathOfLocal);
|
| 78 |
+
|
| 79 |
+
// Run the fuzzer for 10 seconds
|
| 80 |
+
println('Running fuzzer');
|
| 81 |
+
setStatusText('Test specific fuzzer: running fuzzer ' + args.fuzzerName);
|
| 82 |
+
await runFuzzerHandlerCFLite(
|
| 83 |
+
pathOfLocal,
|
| 84 |
+
args.fuzzerName,
|
| 85 |
+
extensionConfig.numberOfSecondsForTestRuns.toString()
|
| 86 |
+
);
|
| 87 |
+
setStatusText('Test specific fuzzer: test completed of ' + args.fuzzerName);
|
| 88 |
+
return;
|
| 89 |
+
}
|
local-test-zookeeper-delta-01/fuzz-tooling/tools/vscode-extension/src/fuzzIntrospectorHelper.ts
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Copyright 2025 Google LLC
|
| 2 |
+
//
|
| 3 |
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
// you may not use this file except in compliance with the License.
|
| 5 |
+
// You may obtain a copy of the License at
|
| 6 |
+
//
|
| 7 |
+
// http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
//
|
| 9 |
+
// Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
// See the License for the specific language governing permissions and
|
| 13 |
+
// limitations under the License.
|
| 14 |
+
//
|
| 15 |
+
////////////////////////////////////////////////////////////////////////////////
|
| 16 |
+
|
| 17 |
+
import * as vscode from 'vscode';
|
| 18 |
+
|
| 19 |
+
import {println} from './logger';
|
| 20 |
+
import {extensionConfig} from './config';
|
| 21 |
+
import {isPathValidOssFuzzPath} from './ossfuzzWrappers';
|
| 22 |
+
import {systemSync} from './utils';
|
| 23 |
+
|
| 24 |
+
const fs = require('fs');
|
| 25 |
+
|
| 26 |
+
export async function setUpFuzzIntrospector() {
|
| 27 |
+
println('Setting up oss-fuzz in /tmp/');
|
| 28 |
+
|
| 29 |
+
// First check if we already have Fuzz Introspector installed.
|
| 30 |
+
const tmpOssFuzzRepositoryPath = '/tmp/fi-tmp-env';
|
| 31 |
+
|
| 32 |
+
if ((await isPathValidOssFuzzPath(tmpOssFuzzRepositoryPath)) === true) {
|
| 33 |
+
println('Fuzz Introspector virtual env already exists in /tmp/fi-tmp-env');
|
| 34 |
+
extensionConfig.ossFuzzPepositoryWorkPath = tmpOssFuzzRepositoryPath;
|
| 35 |
+
return;
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
const cmdToExec = 'python3.11';
|
| 39 |
+
const args: Array<string> = ['-m', 'virtualenv', tmpOssFuzzRepositoryPath];
|
| 40 |
+
const [res, output] = await systemSync(cmdToExec, args);
|
| 41 |
+
if (res === false) {
|
| 42 |
+
println('Failed to create virtual environment');
|
| 43 |
+
println(output);
|
| 44 |
+
return;
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
const cmdToExec2 = '/tmp/fi-tmp-env/bin/python3.11';
|
| 48 |
+
const args2: Array<string> = [
|
| 49 |
+
'-m',
|
| 50 |
+
'pip',
|
| 51 |
+
'install',
|
| 52 |
+
'fuzz-introspector==0.1.6',
|
| 53 |
+
];
|
| 54 |
+
const [res2, output2] = await systemSync(cmdToExec2, args2);
|
| 55 |
+
if (res2 === false) {
|
| 56 |
+
println('Failed to create virtual environment');
|
| 57 |
+
println(output2);
|
| 58 |
+
return;
|
| 59 |
+
}
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
export async function runFuzzIntrospector() {
|
| 63 |
+
println('Setting up oss-fuzz in /tmp/');
|
| 64 |
+
|
| 65 |
+
const workspaceFolder = vscode.workspace.workspaceFolders;
|
| 66 |
+
if (!workspaceFolder) {
|
| 67 |
+
return;
|
| 68 |
+
}
|
| 69 |
+
const pathOfLocal = workspaceFolder[0].uri.fsPath;
|
| 70 |
+
println('path of local: ' + pathOfLocal);
|
| 71 |
+
|
| 72 |
+
// First check if we already have Fuzz Introspector installed.
|
| 73 |
+
const tmpOssFuzzRepositoryPath = '/tmp/fi-tmp-env';
|
| 74 |
+
|
| 75 |
+
if ((await isPathValidOssFuzzPath(tmpOssFuzzRepositoryPath)) === true) {
|
| 76 |
+
println('Fuzz Introspector virtual env already exists in /tmp/fi-tmp-env');
|
| 77 |
+
extensionConfig.ossFuzzPepositoryWorkPath = tmpOssFuzzRepositoryPath;
|
| 78 |
+
return;
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
await systemSync('mkdir', ['-p', '/tmp/out-fi/']);
|
| 82 |
+
|
| 83 |
+
const cmdToExec = '/tmp/fi-tmp-env/bin/fuzz-introspector';
|
| 84 |
+
const args: Array<string> = [
|
| 85 |
+
'full',
|
| 86 |
+
'--target_dir=' + pathOfLocal,
|
| 87 |
+
'--out-dir=/tmp/out-fi',
|
| 88 |
+
];
|
| 89 |
+
const [res, output] = await systemSync(cmdToExec, args);
|
| 90 |
+
if (res === false) {
|
| 91 |
+
println('Failed run FI');
|
| 92 |
+
println(output);
|
| 93 |
+
return;
|
| 94 |
+
}
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
export async function getOptimalTargetsFromIntrospector() {
|
| 98 |
+
if (!fs.existsSync('/tmp/out-fi/summary.json')) {
|
| 99 |
+
println('There are no introspector reports. Please run introspector first');
|
| 100 |
+
}
|
| 101 |
+
const json_data = fs.readFileSync('/tmp/out-fi/summary.json');
|
| 102 |
+
// println(json_data);
|
| 103 |
+
|
| 104 |
+
const jsonCodeCoverage = JSON.parse(json_data);
|
| 105 |
+
|
| 106 |
+
println('Optimal targets');
|
| 107 |
+
Object.entries(jsonCodeCoverage['analyses']['OptimalTargets']).forEach(
|
| 108 |
+
entry => {
|
| 109 |
+
const [key, value] = entry;
|
| 110 |
+
const objectDictionary: any = value as any;
|
| 111 |
+
println(JSON.stringify(objectDictionary, null, 2));
|
| 112 |
+
}
|
| 113 |
+
);
|
| 114 |
+
println('--------------------------');
|
| 115 |
+
|
| 116 |
+
return;
|
| 117 |
+
}
|