Add files using upload-large-folder tool
Browse files- local-test-commons-compress-full-01-vuln_2/fuzz-tooling/infra/__pycache__/constants.cpython-312.pyc +0 -0
- local-test-commons-compress-full-01-vuln_2/fuzz-tooling/infra/__pycache__/templates.cpython-312.pyc +0 -0
- local-test-commons-compress-full-01-vuln_2/fuzz-tooling/infra/base-images/aixcc_build_all.sh +59 -0
- local-test-commons-compress-full-01-vuln_2/fuzz-tooling/infra/ci/requirements.txt +9 -0
- local-test-commons-compress-full-01-vuln_2/fuzz-tooling/infra/uploader/Dockerfile +7 -0
- local-test-commons-compress-full-01-vuln_2/fuzz-tooling/tools/vscode-extension/src/commands/cmdBuildFuzzerFromWorkspace.ts +80 -0
- local-test-commons-compress-full-01-vuln_2/fuzz-tooling/tools/vscode-extension/src/commands/cmdCreateOSSFuzzSetup.ts +28 -0
- local-test-commons-compress-full-01-vuln_2/fuzz-tooling/tools/vscode-extension/src/commands/cmdDispatcherGenerateClusterfuzzLite.ts +38 -0
- local-test-commons-compress-full-01-vuln_2/fuzz-tooling/tools/vscode-extension/src/commands/cmdDisplayCoverage.ts +71 -0
- local-test-commons-compress-full-01-vuln_2/fuzz-tooling/tools/vscode-extension/src/commands/cmdEndToEndCoverage.ts +192 -0
- local-test-commons-compress-full-01-vuln_2/fuzz-tooling/tools/vscode-extension/src/commands/cmdFIGetOptimalTargets.ts +21 -0
- local-test-commons-compress-full-01-vuln_2/fuzz-tooling/tools/vscode-extension/src/commands/cmdListFuzzers.ts +42 -0
- local-test-commons-compress-full-01-vuln_2/fuzz-tooling/tools/vscode-extension/src/commands/cmdRedo.ts +35 -0
- local-test-commons-compress-full-01-vuln_2/fuzz-tooling/tools/vscode-extension/src/commands/cmdRunFuzzer.ts +83 -0
- local-test-commons-compress-full-01-vuln_2/fuzz-tooling/tools/vscode-extension/src/commands/cmdSetOSSFuzzPath.ts +59 -0
- local-test-commons-compress-full-01-vuln_2/fuzz-tooling/tools/vscode-extension/src/commands/cmdSetupCIFuzz.ts +87 -0
- local-test-commons-compress-full-01-vuln_2/fuzz-tooling/tools/vscode-extension/src/commands/cmdSetupFI.ts +24 -0
- local-test-commons-compress-full-01-vuln_2/fuzz-tooling/tools/vscode-extension/src/commands/cmdSetupOSSFuzz.ts +53 -0
- local-test-commons-compress-full-01-vuln_2/fuzz-tooling/tools/vscode-extension/src/commands/cmdTemplate.ts +357 -0
- local-test-commons-compress-full-01-vuln_2/fuzz-tooling/tools/vscode-extension/src/config.ts +37 -0
local-test-commons-compress-full-01-vuln_2/fuzz-tooling/infra/__pycache__/constants.cpython-312.pyc
ADDED
|
Binary file (802 Bytes). View file
|
|
|
local-test-commons-compress-full-01-vuln_2/fuzz-tooling/infra/__pycache__/templates.cpython-312.pyc
ADDED
|
Binary file (3.04 kB). View file
|
|
|
local-test-commons-compress-full-01-vuln_2/fuzz-tooling/infra/base-images/aixcc_build_all.sh
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash -eux
|
| 2 |
+
|
| 3 |
+
if [ "$1" = "--cache-from" ]; then
|
| 4 |
+
PULL_CACHE=1
|
| 5 |
+
shift
|
| 6 |
+
CACHE_TAG="${1//\//-}" # s/\//-/g -> for branch names that contain slashes
|
| 7 |
+
shift
|
| 8 |
+
elif [ "$1" = "--cache-to" ]; then
|
| 9 |
+
PUSH_CACHE=1
|
| 10 |
+
shift
|
| 11 |
+
CACHE_TAG="${1//\//-}" # s/\//-/g -> for branch names that contain slashes
|
| 12 |
+
shift
|
| 13 |
+
fi
|
| 14 |
+
|
| 15 |
+
ARG_TAG="$1"
|
| 16 |
+
shift
|
| 17 |
+
|
| 18 |
+
BASE_IMAGES=(
|
| 19 |
+
"ghcr.io/aixcc-finals/base-image infra/base-images/base-image"
|
| 20 |
+
"ghcr.io/aixcc-finals/base-clang infra/base-images/base-clang"
|
| 21 |
+
"ghcr.io/aixcc-finals/base-builder infra/base-images/base-builder"
|
| 22 |
+
"ghcr.io/aixcc-finals/base-builder-go infra/base-images/base-builder-go"
|
| 23 |
+
"ghcr.io/aixcc-finals/base-builder-jvm infra/base-images/base-builder-jvm"
|
| 24 |
+
"ghcr.io/aixcc-finals/base-builder-python infra/base-images/base-builder-python"
|
| 25 |
+
"ghcr.io/aixcc-finals/base-builder-rust infra/base-images/base-builder-rust"
|
| 26 |
+
"ghcr.io/aixcc-finals/base-builder-ruby infra/base-images/base-builder-ruby"
|
| 27 |
+
"ghcr.io/aixcc-finals/base-builder-swift infra/base-images/base-builder-swift"
|
| 28 |
+
"ghcr.io/aixcc-finals/base-runner infra/base-images/base-runner"
|
| 29 |
+
"ghcr.io/aixcc-finals/base-runner-debug infra/base-images/base-runner-debug"
|
| 30 |
+
)
|
| 31 |
+
|
| 32 |
+
for tuple in "${BASE_IMAGES[@]}"; do
|
| 33 |
+
read -r image path <<< "$tuple"
|
| 34 |
+
|
| 35 |
+
if [ "${PULL_CACHE+x}" ]; then
|
| 36 |
+
|
| 37 |
+
docker buildx build \
|
| 38 |
+
--build-arg IMG_TAG="${ARG_TAG}" \
|
| 39 |
+
--cache-from=type=registry,ref="${image}:${CACHE_TAG}" \
|
| 40 |
+
--tag "${image}:${ARG_TAG}" --push "$@" "${path}"
|
| 41 |
+
|
| 42 |
+
elif [ "${PUSH_CACHE+x}" ]; then
|
| 43 |
+
|
| 44 |
+
docker buildx build \
|
| 45 |
+
--build-arg IMG_TAG="${ARG_TAG}" \
|
| 46 |
+
--cache-from=type=registry,ref="${image}:${CACHE_TAG}" \
|
| 47 |
+
--cache-to=type=registry,ref="${image}:${CACHE_TAG}",mode=max \
|
| 48 |
+
--tag "${image}:${ARG_TAG}" --push "$@" "${path}"
|
| 49 |
+
|
| 50 |
+
else
|
| 51 |
+
|
| 52 |
+
docker buildx build \
|
| 53 |
+
--build-arg IMG_TAG="${ARG_TAG}" \
|
| 54 |
+
--tag "${image}:${ARG_TAG}" --push "$@" "${path}"
|
| 55 |
+
|
| 56 |
+
fi
|
| 57 |
+
|
| 58 |
+
done
|
| 59 |
+
|
local-test-commons-compress-full-01-vuln_2/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-commons-compress-full-01-vuln_2/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-commons-compress-full-01-vuln_2/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-commons-compress-full-01-vuln_2/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-commons-compress-full-01-vuln_2/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-commons-compress-full-01-vuln_2/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-commons-compress-full-01-vuln_2/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-commons-compress-full-01-vuln_2/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-commons-compress-full-01-vuln_2/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-commons-compress-full-01-vuln_2/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-commons-compress-full-01-vuln_2/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-commons-compress-full-01-vuln_2/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-commons-compress-full-01-vuln_2/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-commons-compress-full-01-vuln_2/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-commons-compress-full-01-vuln_2/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-commons-compress-full-01-vuln_2/fuzz-tooling/tools/vscode-extension/src/commands/cmdTemplate.ts
ADDED
|
@@ -0,0 +1,357 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 {println} from '../logger';
|
| 23 |
+
|
| 24 |
+
export const cLangSimpleStringFuzzer = `#include <stdint.h>
|
| 25 |
+
#include <string.h>
|
| 26 |
+
#include <stdlib.h>
|
| 27 |
+
|
| 28 |
+
int
|
| 29 |
+
LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
| 30 |
+
{
|
| 31 |
+
char *new_str = (char *)malloc(size+1);
|
| 32 |
+
if (new_str == NULL){
|
| 33 |
+
return 0;
|
| 34 |
+
}
|
| 35 |
+
memcpy(new_str, data, size);
|
| 36 |
+
new_str[size] = '\\0';
|
| 37 |
+
|
| 38 |
+
// Insert fuzzer contents here
|
| 39 |
+
// fuzz data in new_str
|
| 40 |
+
|
| 41 |
+
// end of fuzzer contents
|
| 42 |
+
|
| 43 |
+
free(new_str);
|
| 44 |
+
return 0;
|
| 45 |
+
}`;
|
| 46 |
+
|
| 47 |
+
const cLangFileInputFuzzer = `int
|
| 48 |
+
LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
| 49 |
+
{
|
| 50 |
+
char filename[256];
|
| 51 |
+
sprintf(filename, "/tmp/libfuzzer.%d", getpid());
|
| 52 |
+
|
| 53 |
+
// Create a file on the filesystem with fuzzer data in it
|
| 54 |
+
FILE *fp = fopen(filename, "wb");
|
| 55 |
+
if (!fp) {
|
| 56 |
+
return 0;
|
| 57 |
+
}
|
| 58 |
+
fwrite(data, size, 1, fp);
|
| 59 |
+
fclose(fp);
|
| 60 |
+
|
| 61 |
+
// Fuzzer logic here. Use the file as a source of data.
|
| 62 |
+
|
| 63 |
+
// Fuzzer logic end
|
| 64 |
+
|
| 65 |
+
// Clean up the file.
|
| 66 |
+
unlink(filename);
|
| 67 |
+
|
| 68 |
+
return 0;
|
| 69 |
+
}`;
|
| 70 |
+
|
| 71 |
+
const cLangBareTemplateFuzzer = `int
|
| 72 |
+
LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
| 73 |
+
{
|
| 74 |
+
return 0;
|
| 75 |
+
}`;
|
| 76 |
+
|
| 77 |
+
const cppLangBareTemplateFuzzer = `extern "C" int
|
| 78 |
+
LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
| 79 |
+
{
|
| 80 |
+
return 0;
|
| 81 |
+
}`;
|
| 82 |
+
|
| 83 |
+
const cppLangStdStringTemplateFuzzer = `extern "C" int
|
| 84 |
+
LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
| 85 |
+
{
|
| 86 |
+
std::string input(reinterpret_cast<const char*>(data), size);
|
| 87 |
+
|
| 88 |
+
return 0;
|
| 89 |
+
}`;
|
| 90 |
+
|
| 91 |
+
export const cppLangFDPTemplateFuzzer = `#include <fuzzer/FuzzedDataProvider.h>
|
| 92 |
+
|
| 93 |
+
#include <string>
|
| 94 |
+
|
| 95 |
+
extern "C" int
|
| 96 |
+
LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
| 97 |
+
{
|
| 98 |
+
FuzzedDataProvider fdp(data, size);
|
| 99 |
+
|
| 100 |
+
// Extract higher level data types used for fuzzing, e.g.
|
| 101 |
+
// int ran_int = fdp.ConsumeIntegralInRange<int>(1, 1024);
|
| 102 |
+
// std::string s = fdp.ConsumeRandomLengthString();
|
| 103 |
+
|
| 104 |
+
return 0;
|
| 105 |
+
}`;
|
| 106 |
+
|
| 107 |
+
const cppLangFileInputFuzzer = `extern "C" int
|
| 108 |
+
LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
| 109 |
+
{
|
| 110 |
+
char filename[256];
|
| 111 |
+
sprintf(filename, "/tmp/libfuzzer.%d", getpid());
|
| 112 |
+
|
| 113 |
+
FILE *fp = fopen(filename, "wb");
|
| 114 |
+
if (!fp) {
|
| 115 |
+
return 0;
|
| 116 |
+
}
|
| 117 |
+
fwrite(data, size, 1, fp);
|
| 118 |
+
fclose(fp);
|
| 119 |
+
|
| 120 |
+
// Fuzzer logic here
|
| 121 |
+
|
| 122 |
+
// Fuzzer logic end
|
| 123 |
+
|
| 124 |
+
unlink(filename);
|
| 125 |
+
}`;
|
| 126 |
+
|
| 127 |
+
const pythonLangBareTemplate = `import sys
|
| 128 |
+
import atheris
|
| 129 |
+
|
| 130 |
+
|
| 131 |
+
def TestOneInput(fuzz_bytes):
|
| 132 |
+
return
|
| 133 |
+
|
| 134 |
+
|
| 135 |
+
def main():
|
| 136 |
+
atheris.Setup(sys.argv, TestOneInput)
|
| 137 |
+
atheris.Fuzz()
|
| 138 |
+
|
| 139 |
+
|
| 140 |
+
if __name__ == "__main__":
|
| 141 |
+
main()`;
|
| 142 |
+
|
| 143 |
+
export const pythonLangFileInputFuzzer = `import sys
|
| 144 |
+
import atheris
|
| 145 |
+
|
| 146 |
+
@atheris.instrument_func
|
| 147 |
+
def TestOneInput(data):
|
| 148 |
+
# Write fuzz data to a file
|
| 149 |
+
with open('/tmp/fuzz_input.b') as f:
|
| 150 |
+
f.write(data)
|
| 151 |
+
|
| 152 |
+
# Use '/tmp/fuzz_input.b' as input to file handling logic.
|
| 153 |
+
|
| 154 |
+
|
| 155 |
+
def main():
|
| 156 |
+
atheris.instrument_all()
|
| 157 |
+
atheris.Setup(sys.argv, TestOneInput)
|
| 158 |
+
atheris.Fuzz()
|
| 159 |
+
|
| 160 |
+
|
| 161 |
+
if __name__ == "__main__":
|
| 162 |
+
main()`;
|
| 163 |
+
|
| 164 |
+
const pythonLongFdpTemplate = `import sys
|
| 165 |
+
import atheris
|
| 166 |
+
|
| 167 |
+
def TestOneInput(fuzz_bytes):
|
| 168 |
+
fdp = atheris.FuzzedDataProvider(fuzz_bytes)
|
| 169 |
+
return
|
| 170 |
+
|
| 171 |
+
def main():
|
| 172 |
+
atheris.Setup(sys.argv, TestOneInput)
|
| 173 |
+
atheris.Fuzz()
|
| 174 |
+
|
| 175 |
+
if __name__ == "__main__":
|
| 176 |
+
main()`;
|
| 177 |
+
|
| 178 |
+
export const javaLangBareTemplate = `import com.code_intelligence.jazzer.api.FuzzedDataProvider;
|
| 179 |
+
public class SampleFuzzer {
|
| 180 |
+
public static void fuzzerTestOneInput(FuzzedDataProvider fdp) {
|
| 181 |
+
// Use fdp to create arbitrary types seeded with fuzz data
|
| 182 |
+
}
|
| 183 |
+
}
|
| 184 |
+
`;
|
| 185 |
+
|
| 186 |
+
/**
|
| 187 |
+
* C templates
|
| 188 |
+
*/
|
| 189 |
+
async function cTemplates() {
|
| 190 |
+
let template = '';
|
| 191 |
+
const result = await vscode.window.showQuickPick(
|
| 192 |
+
['Bare template', 'Null-terminated string input', 'File input'],
|
| 193 |
+
{
|
| 194 |
+
placeHolder: 'Pick which template',
|
| 195 |
+
}
|
| 196 |
+
);
|
| 197 |
+
vscode.window.showInformationMessage(`Got: ${result}`);
|
| 198 |
+
|
| 199 |
+
if (result === 'Null-terminated string input') {
|
| 200 |
+
template = cLangSimpleStringFuzzer;
|
| 201 |
+
} else if (result === 'File input') {
|
| 202 |
+
template = cLangFileInputFuzzer;
|
| 203 |
+
} else if (result === 'Bare template') {
|
| 204 |
+
template = cLangBareTemplateFuzzer;
|
| 205 |
+
} else {
|
| 206 |
+
template = 'empty';
|
| 207 |
+
}
|
| 208 |
+
const workspaceFolder = vscode.workspace.workspaceFolders;
|
| 209 |
+
if (!workspaceFolder) {
|
| 210 |
+
return;
|
| 211 |
+
}
|
| 212 |
+
|
| 213 |
+
const wsPath = workspaceFolder[0].uri.fsPath; // gets the path of the first workspace folder
|
| 214 |
+
|
| 215 |
+
const cifuzzYml = vscode.Uri.file(wsPath + '/oss-fuzz-template.c');
|
| 216 |
+
const wsedit = new vscode.WorkspaceEdit();
|
| 217 |
+
wsedit.createFile(cifuzzYml, {ignoreIfExists: true});
|
| 218 |
+
wsedit.insert(cifuzzYml, new vscode.Position(0, 0), template);
|
| 219 |
+
vscode.workspace.applyEdit(wsedit);
|
| 220 |
+
return;
|
| 221 |
+
}
|
| 222 |
+
|
| 223 |
+
/**
|
| 224 |
+
* CPP templates
|
| 225 |
+
*/
|
| 226 |
+
async function cppTemplates() {
|
| 227 |
+
let template = '';
|
| 228 |
+
const result = await vscode.window.showQuickPick(
|
| 229 |
+
[
|
| 230 |
+
'Bare template',
|
| 231 |
+
'Simple CPP string',
|
| 232 |
+
'File input fuzzer',
|
| 233 |
+
'Fuzzed data provider',
|
| 234 |
+
],
|
| 235 |
+
{
|
| 236 |
+
placeHolder: 'Pick which template',
|
| 237 |
+
}
|
| 238 |
+
);
|
| 239 |
+
vscode.window.showInformationMessage(`Got: ${result}`);
|
| 240 |
+
|
| 241 |
+
if (result === 'Bare template') {
|
| 242 |
+
template = cppLangBareTemplateFuzzer;
|
| 243 |
+
} else if (result === 'Simple CPP string') {
|
| 244 |
+
template = cppLangStdStringTemplateFuzzer;
|
| 245 |
+
} else if (result === 'File input fuzzer') {
|
| 246 |
+
template = cppLangFileInputFuzzer;
|
| 247 |
+
} else if (result === 'Fuzzed data provider') {
|
| 248 |
+
template = cppLangFDPTemplateFuzzer;
|
| 249 |
+
} else {
|
| 250 |
+
template = 'empty';
|
| 251 |
+
}
|
| 252 |
+
const workspaceFolder = vscode.workspace.workspaceFolders;
|
| 253 |
+
if (!workspaceFolder) {
|
| 254 |
+
return;
|
| 255 |
+
}
|
| 256 |
+
|
| 257 |
+
const wsPath = workspaceFolder[0].uri.fsPath; // gets the path of the first workspace folder
|
| 258 |
+
|
| 259 |
+
const cifuzzYml = vscode.Uri.file(wsPath + '/oss-fuzz-template.cpp');
|
| 260 |
+
const wsedit = new vscode.WorkspaceEdit();
|
| 261 |
+
wsedit.createFile(cifuzzYml, {ignoreIfExists: true});
|
| 262 |
+
wsedit.insert(cifuzzYml, new vscode.Position(0, 0), template);
|
| 263 |
+
vscode.workspace.applyEdit(wsedit);
|
| 264 |
+
return;
|
| 265 |
+
}
|
| 266 |
+
|
| 267 |
+
/**
|
| 268 |
+
* Python templates
|
| 269 |
+
*/
|
| 270 |
+
async function pythonTepmlates() {
|
| 271 |
+
let template = '';
|
| 272 |
+
const result = await vscode.window.showQuickPick(
|
| 273 |
+
['Bare template', 'Fuzzed Data Provider', 'File input fuzzer'],
|
| 274 |
+
{
|
| 275 |
+
placeHolder: 'Pick which template',
|
| 276 |
+
}
|
| 277 |
+
);
|
| 278 |
+
vscode.window.showInformationMessage(`Got: ${result}`);
|
| 279 |
+
|
| 280 |
+
if (result === 'Fuzzed Data Provider') {
|
| 281 |
+
template = pythonLongFdpTemplate;
|
| 282 |
+
} else if (result === 'Bare template') {
|
| 283 |
+
template = pythonLangBareTemplate;
|
| 284 |
+
} else if (result === 'File input fuzzer') {
|
| 285 |
+
template = pythonLangFileInputFuzzer;
|
| 286 |
+
} else {
|
| 287 |
+
template = 'empty';
|
| 288 |
+
}
|
| 289 |
+
const workspaceFolder = vscode.workspace.workspaceFolders;
|
| 290 |
+
if (!workspaceFolder) {
|
| 291 |
+
return;
|
| 292 |
+
}
|
| 293 |
+
|
| 294 |
+
const wsPath = workspaceFolder[0].uri.fsPath; // gets the path of the first workspace folder
|
| 295 |
+
|
| 296 |
+
const cifuzzYml = vscode.Uri.file(wsPath + '/oss-fuzz-template.py');
|
| 297 |
+
const wsedit = new vscode.WorkspaceEdit();
|
| 298 |
+
wsedit.createFile(cifuzzYml, {ignoreIfExists: true});
|
| 299 |
+
wsedit.insert(cifuzzYml, new vscode.Position(0, 0), template);
|
| 300 |
+
vscode.workspace.applyEdit(wsedit);
|
| 301 |
+
return;
|
| 302 |
+
}
|
| 303 |
+
|
| 304 |
+
/**
|
| 305 |
+
* Java templates
|
| 306 |
+
*/
|
| 307 |
+
async function javaTemplates() {
|
| 308 |
+
let template = '';
|
| 309 |
+
const result = await vscode.window.showQuickPick(['Bare template'], {
|
| 310 |
+
placeHolder: 'Pick which template',
|
| 311 |
+
});
|
| 312 |
+
vscode.window.showInformationMessage(`Got: ${result}`);
|
| 313 |
+
|
| 314 |
+
if (result === 'Bare template') {
|
| 315 |
+
template = javaLangBareTemplate;
|
| 316 |
+
} else {
|
| 317 |
+
template = 'empty';
|
| 318 |
+
}
|
| 319 |
+
const workspaceFolder = vscode.workspace.workspaceFolders;
|
| 320 |
+
if (!workspaceFolder) {
|
| 321 |
+
return;
|
| 322 |
+
}
|
| 323 |
+
|
| 324 |
+
const wsPath = workspaceFolder[0].uri.fsPath; // gets the path of the first workspace folder
|
| 325 |
+
|
| 326 |
+
const cifuzzYml = vscode.Uri.file(wsPath + '/oss-fuzz-template.java');
|
| 327 |
+
const wsedit = new vscode.WorkspaceEdit();
|
| 328 |
+
wsedit.createFile(cifuzzYml, {ignoreIfExists: true});
|
| 329 |
+
wsedit.insert(cifuzzYml, new vscode.Position(0, 0), template);
|
| 330 |
+
vscode.workspace.applyEdit(wsedit);
|
| 331 |
+
return;
|
| 332 |
+
}
|
| 333 |
+
|
| 334 |
+
export async function cmdDispatcherTemplate(context: vscode.ExtensionContext) {
|
| 335 |
+
println('Creating template');
|
| 336 |
+
const options: {
|
| 337 |
+
[key: string]: (context: vscode.ExtensionContext) => Promise<void>;
|
| 338 |
+
} = {
|
| 339 |
+
C: cTemplates,
|
| 340 |
+
CPP: cppTemplates,
|
| 341 |
+
Python: pythonTepmlates,
|
| 342 |
+
Java: javaTemplates,
|
| 343 |
+
};
|
| 344 |
+
|
| 345 |
+
const quickPick = vscode.window.createQuickPick();
|
| 346 |
+
quickPick.items = Object.keys(options).map(label => ({label}));
|
| 347 |
+
quickPick.onDidChangeSelection(selection => {
|
| 348 |
+
if (selection[0]) {
|
| 349 |
+
options[selection[0].label](context).catch(console.error);
|
| 350 |
+
}
|
| 351 |
+
});
|
| 352 |
+
quickPick.onDidHide(() => quickPick.dispose());
|
| 353 |
+
quickPick.placeholder = 'Pick language';
|
| 354 |
+
quickPick.show();
|
| 355 |
+
|
| 356 |
+
return;
|
| 357 |
+
}
|
local-test-commons-compress-full-01-vuln_2/fuzz-tooling/tools/vscode-extension/src/config.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
|
| 19 |
+
export class ExtensionConfig {
|
| 20 |
+
/** Path to the repository that will be used. */
|
| 21 |
+
ossFuzzPepositoryWorkPath: string = '/tmp/oss-fuzz';
|
| 22 |
+
|
| 23 |
+
/** The directory where crash info is stored. */
|
| 24 |
+
crashesDirectory = process.env.HOME + '/oss-fuzz-crashes';
|
| 25 |
+
|
| 26 |
+
/** Number of seconds used for running quick test fuzzers */
|
| 27 |
+
numberOfSecondsForTestRuns = 20;
|
| 28 |
+
|
| 29 |
+
async printConfig() {
|
| 30 |
+
println('Config:');
|
| 31 |
+
println('- OSS-Fuzz repository path: ' + this.ossFuzzPepositoryWorkPath);
|
| 32 |
+
println('- Crashes directory: ' + this.crashesDirectory);
|
| 33 |
+
println('- numberOfSecondsForTestRuns: ' + this.numberOfSecondsForTestRuns);
|
| 34 |
+
}
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
export const extensionConfig = new ExtensionConfig();
|