Skip to content

Commit 5f14111

Browse files
committed
Handle path to binary with custom build arguments, add readme & vscodeignore
1 parent 27b08a7 commit 5f14111

File tree

5 files changed

+56
-13
lines changed

5 files changed

+56
-13
lines changed

.vscodeignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules/**
2+
*.vsix
3+
readme.md
4+
.gitignore

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# cifuzz VScode extension
2+
3+
4+
## Development
5+
1. Open `extension.js` in VS code
6+
2. Press **F5** (or **Ctrl+F5**) to launch a new Extension Development Host.
7+
8+
## Release
9+
1. (Optional) Install the VS Code Extension Manager:
10+
```bash
11+
npm install -g @vscode/vsce
12+
```
13+
2. From the project root, run
14+
```bash
15+
vsce package
16+
```

extension.js

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ async function generateProfiles() {
6666

6767
const engine = cfg.engine || 'libfuzzer-clang';
6868
const sanitizers = cfg.sanitizers || ['address+undefined'];
69-
const searchBuildDir = path.join(root, CIFUZZ_BUILD, engine, sanitizers.join('+'));
69+
const engineDir = path.join(root, CIFUZZ_BUILD, engine);
70+
const searchPrefix = sanitizers.join('+');
7071

7172
const launch = {
7273
version: '0.2.0',
@@ -89,9 +90,30 @@ async function generateProfiles() {
8990
else if (fn === test) { candidates.push(fp); }
9091
}
9192
}
92-
walk(searchBuildDir);
93-
if (candidates.length !== 1) { continue; }
93+
94+
// Binary can be in different path, based on the engine args (eg address+undefined-D4JOLPY3)
95+
// As we don't know which one cifuzz will use, we just take the latest binary built
96+
if (fs.existsSync(engineDir)) {
97+
const matchingDirs = fs.readdirSync(engineDir).filter(entry => {
98+
const fullPath = path.join(engineDir, entry);
99+
return fs.statSync(fullPath).isDirectory() && entry.startsWith(searchPrefix);
100+
});
101+
102+
for (const dir of matchingDirs) {
103+
walk(path.join(engineDir, dir));
104+
}
105+
}
106+
console.warn(candidates);
107+
108+
if (candidates.length === 0) {
109+
console.warn("Cannot find binary for ", test);
110+
continue;
111+
}
112+
113+
// Sort by creation date
114+
candidates.sort((a, b) => fs.statSync(b).mtimeMs - fs.statSync(a).mtimeMs);
94115
const bin = candidates[0];
116+
console.warn(bin)
95117

96118
const crashingInputPath = path.join(root, FINDINGS_DIR, id, 'crashing-input');
97119

@@ -178,7 +200,7 @@ async function addFindingBreakpoint() {
178200
}
179201

180202
function activate(context) {
181-
console.log("✅ cifuzz Debug Generator: activate() called");
203+
182204

183205
const generateProfilesCommand = vscode.commands.registerCommand('cifuzz.generateDebugProfiles', async () => {
184206
try {

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
{
22
"name": "cifuzz-vscode-extension",
3-
"displayName": "cifuzz vscode helper extension",
4-
"description": "Helper VScode extension for cifuzz",
5-
"version": "0.1.0",
3+
"displayName": "CI Fuzz vscode helper extension",
4+
"description": "Helper VScode extension for CI Fuzz",
5+
"version": "0.1.1",
66
"engines": {
77
"vscode": "^1.75.0"
88
},
99
"activationEvents": [],
1010
"main": "./extension.js",
11+
"repository": "https://github.com/CodeIntelligenceTesting/cifuzz-vscode-extension",
1112
"contributes": {
1213
"commands": [
1314
{
1415
"command": "cifuzz.generateDebugProfiles",
15-
"title": "cifuzz: Generate Debug Profiles"
16+
"title": "CI Fuzz: Generate Debug Profiles"
1617
},
1718
{
1819
"command": "cifuzz.addFindingBreakpoint",
19-
"title": "cifuzz: Add Finding Breakpoint"
20+
"title": "CI Fuzz: Add Finding Breakpoint"
2021
}
2122
]
2223
},

0 commit comments

Comments
 (0)