Skip to content

Commit 2f6f251

Browse files
committed
Fix Breadcrumbs webview and update README
1 parent d568e20 commit 2f6f251

9 files changed

Lines changed: 63 additions & 47 deletions

File tree

README.md

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -38,35 +38,19 @@ Security Notes allows the creation of notes within source files, which can be re
3838

3939
![Demo for basic usage](images/demo-basic-usage.gif)
4040

41-
## Breadcrumb Trails
42-
43-
Breadcrumbs let you capture the path you follow while reverse-engineering a feature. Start a trail with `Security Notes: Create Breadcrumb Trail`, highlight the snippets you visit, and run `Security Notes: Add Breadcrumb Crumb` to drop "crumbs" along the way. Each crumb stores the code selection, file/line information, and an optional note.
44-
45-
Open the **Breadcrumbs** view from the Security Notes activity bar to see an interactive diagram of the active trail. Click any crumb in the diagram to jump back to that snippet in the editor, or switch trails from the dropdown to review other investigations. Trails are stored locally in `.security-notes-breadcrumbs.json` so you can revisit them later, and you can export the active trail to a Markdown report (via `Security Notes: Export Breadcrumb Trail` or the Export button) ready to paste into docs or reports.
46-
4741
## Local database for Comments
4842

4943
By default your notes are backed up in a JSON file once you close VSCode. Once you open the project again, saved comments are loaded and shown on the UI.
5044

51-
## Collaboration Mode
52-
53-
Because chasing bugs with friends is more fun :)
54-
55-
Security Notes allows sharing of notes in real-time with other users. To do so, it leverages the RethinkDB real-time database.
56-
57-
First, make sure you have a RethinkDB database instance up and running. Then set your author name, and the database connection information in the extension's settings, and you are ready to go! Please see the section below for more details).
58-
59-
Collaboration mode in action:
60-
61-
![Demo for collaboration](images/demo-collaboration.gif)
45+
## Breadcrumb Trails
6246

63-
### Setting up the RethinkDB database
47+
Breadcrumbs let you capture the path you follow while reverse-engineering a feature. Start a trail with `Security Notes: Create Breadcrumb Trail`, highlight the snippets you visit, and run `Security Notes: Add Breadcrumb to Trail` to drop "crumbs" along the way. Each crumb stores the code selection, file/line information, and an optional note.
6448

65-
We recommend following instructions in RethinkDB [installation guide](https://rethinkdb.com/docs/install/). Additionally, following [hardening steps](https://rethinkdb.com/docs/security/#wrapper), such as setting a password for the `admin` user and setting up SSL/TLS, are strongly encouraged.
49+
![Breadcrumbs view showing a trail](images/breadcrumbs-1.png)
6650

67-
Naturally, you will want to collaborate with remote peers. To do so in a secure way, we recommend setting up access to RethinkDB via SSH or through a VPN like [Tailscale](http://tailscale.com). This way, you avoid having to expose the instance to any network, and also ensuring information in transit is encrypted.
51+
Open the **Breadcrumbs** view from the Security Notes activity bar to see an interactive diagram of the active trail. Click any crumb in the diagram to jump back to that snippet in the editor, or switch trails from the dropdown to review other investigations. Trails are stored locally in `.security-notes-breadcrumbs.json` so you can revisit them later, and you can export the active trail to a Markdown report (via `Security Notes: Export Breadcrumb Trail` or the Export button) ready to paste into docs or reports.
6852

69-
> **Important Notices:** When collaborating with others, ensure that all VSCode instances open the project from the same relative location. For example, if the source code repository you're reviewing has a directory structure like `source_code/app/src`, all peers should open VScode at the same level. Security Notes will store note location using relative paths, so they should be consistent. Also, after enabling the collaboration setting, VSCode would need to be restarted/reloaded for the change to have effect.
53+
![Markdown export of a Breadcrumb](images/breadcrumbs-2.png)
7054

7155
## Importing SAST results
7256

@@ -97,6 +81,26 @@ gosec -fmt=json -out=gosec-results.json ./...
9781
semgrep scan --json -o semgrep-results.json --config=auto .
9882
```
9983

84+
## Collaboration Mode
85+
86+
Because chasing bugs with friends is more fun :)
87+
88+
Security Notes allows sharing of notes in real-time with other users. To do so, it leverages the RethinkDB real-time database.
89+
90+
First, make sure you have a RethinkDB database instance up and running. Then set your author name, and the database connection information in the extension's settings, and you are ready to go! Please see the section below for more details).
91+
92+
Collaboration mode in action:
93+
94+
![Demo for collaboration](images/demo-collaboration.gif)
95+
96+
### Setting up the RethinkDB database
97+
98+
We recommend following instructions in RethinkDB [installation guide](https://rethinkdb.com/docs/install/). Additionally, following [hardening steps](https://rethinkdb.com/docs/security/#wrapper), such as setting a password for the `admin` user and setting up SSL/TLS, are strongly encouraged.
99+
100+
Naturally, you will want to collaborate with remote peers. To do so in a secure way, we recommend setting up access to RethinkDB via SSH or through a VPN like [Tailscale](http://tailscale.com). This way, you avoid having to expose the instance to any network, and also ensuring information in transit is encrypted.
101+
102+
> **Important Notices:** When collaborating with others, ensure that all VSCode instances open the project from the same relative location. For example, if the source code repository you're reviewing has a directory structure like `source_code/app/src`, all peers should open VScode at the same level. Security Notes will store note location using relative paths, so they should be consistent. Also, after enabling the collaboration setting, VSCode would need to be restarted/reloaded for the change to have effect.
103+
100104
## Exporting notes in popular formats
101105

102106
Currently we only support exporting notes to Markdown, but other formats such as HTML are coming soon.

images/breadcrumbs-1.png

440 KB
Loading

images/breadcrumbs-2.png

218 KB
Loading

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,15 @@
9191
},
9292
{
9393
"command": "security-notes.breadcrumbs.addCrumb",
94-
"title": "Security Notes: Add Breadcrumb Crumb"
94+
"title": "Security Notes: Add Breadcrumb to Trail"
9595
},
9696
{
9797
"command": "security-notes.breadcrumbs.removeCrumb",
9898
"title": "Security Notes: Remove Breadcrumb Crumb"
9999
},
100100
{
101101
"command": "security-notes.breadcrumbs.editCrumbNote",
102-
"title": "Security Notes: Edit Breadcrumb Crumb Note"
102+
"title": "Security Notes: Edit Breadcrumb Note"
103103
},
104104
{
105105
"command": "security-notes.breadcrumbs.showTrailDiagram",
@@ -320,4 +320,4 @@
320320
"rethinkdb": "^2.4.2",
321321
"uuid": "^9.0.0"
322322
}
323-
}
323+
}

src/breadcrumbs/commands.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import { fullPathToRelative } from '../utils';
77
import { formatRangeLabel, snippetPreview } from './format';
88
import { exportTrailToMarkdown } from './export';
99

10+
let lastActiveEditor: vscode.TextEditor | undefined = vscode.window.activeTextEditor ?? undefined;
11+
1012
interface TrailQuickPickItem extends vscode.QuickPickItem {
1113
trail: Trail;
1214
}
@@ -115,6 +117,14 @@ export const registerBreadcrumbCommands = (
115117
) => {
116118
const disposables: vscode.Disposable[] = [];
117119

120+
disposables.push(
121+
vscode.window.onDidChangeActiveTextEditor((editor) => {
122+
if (editor) {
123+
lastActiveEditor = editor;
124+
}
125+
}),
126+
);
127+
118128
disposables.push(
119129
vscode.commands.registerCommand('security-notes.breadcrumbs.createTrail', async () => {
120130
const name = await vscode.window.showInputBox({
@@ -156,14 +166,16 @@ export const registerBreadcrumbCommands = (
156166

157167
disposables.push(
158168
vscode.commands.registerCommand('security-notes.breadcrumbs.addCrumb', async () => {
159-
const editor = vscode.window.activeTextEditor;
169+
const editor = vscode.window.activeTextEditor ?? lastActiveEditor;
160170
if (!editor) {
161171
vscode.window.showInformationMessage(
162172
'[Breadcrumbs] Open a file and select the code you want to add as a crumb.',
163173
);
164174
return;
165175
}
166176

177+
await vscode.commands.executeCommand('workbench.action.focusActiveEditorGroup');
178+
167179
const trail = await ensureActiveTrail(store);
168180
if (!trail) {
169181
return;

src/breadcrumbs/export.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,8 @@ const buildSummary = (trail: Trail) => {
2121
lines.push(headline(2, 'Summary'));
2222
lines.push('');
2323
lines.push(`- **Total crumbs:** ${trail.crumbs.length}`);
24-
lines.push(`- **Files touched:** ${files.size}`);
24+
lines.push(`- **Source Files Involved:** ${files.size}`);
2525
lines.push(`- **Generated:** ${formatDate(new Date().toISOString())}`);
26-
if (first && last) {
27-
lines.push(`- **Investigation window:** ${first}${last}`);
28-
}
2926
lines.push('');
3027
return lines.join('\n');
3128
};
@@ -81,9 +78,9 @@ export const exportTrailToMarkdown = async (trail: Trail, uri?: vscode.Uri) => {
8178
const fileNameSafe = trail.name.replace(/[^a-z0-9\-_]+/gi, '-').replace(/-+/g, '-');
8279
const defaultUri = vscode.workspace.workspaceFolders?.length
8380
? vscode.Uri.joinPath(
84-
vscode.workspace.workspaceFolders[0].uri,
85-
`${fileNameSafe || 'breadcrumb-trail'}.md`,
86-
)
81+
vscode.workspace.workspaceFolders[0].uri,
82+
`${fileNameSafe || 'breadcrumb-trail'}-Breadcrumb.md`,
83+
)
8784
: undefined;
8885

8986
uri = await vscode.window.showSaveDialog({

src/webviews/assets/breadcrumbs.css

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
}
1313

1414
.breadcrumbs-subtitle {
15-
margin: 0.25rem 0 0;
15+
margin: 0.10rem 0 0;
1616
color: var(--vscode-descriptionForeground);
1717
font-size: 0.85rem;
1818
}
@@ -29,6 +29,7 @@
2929
border-radius: 4px;
3030
padding: 0.3rem 0.8rem;
3131
cursor: pointer;
32+
white-space: nowrap;
3233
}
3334

3435
.breadcrumbs-button:hover {
@@ -114,10 +115,11 @@
114115
font-size: 0.75rem;
115116
letter-spacing: 0.06em;
116117
text-transform: uppercase;
117-
background: var(--vscode-textLink-activeForeground, rgba(100, 149, 237, 0.25));
118-
color: var(--vscode-textLink-foreground);
119-
border-radius: 999px;
120-
padding: 0.1rem 0.6rem;
118+
background: var(--vscode-editorWidget-background);
119+
border: 1px solid var(--vscode-editorWidget-border);
120+
color: var(--vscode-editor-foreground);
121+
border-radius: 5px;
122+
padding: 0.15rem 0.5rem;
121123
font-weight: 600;
122124
}
123125

@@ -182,4 +184,4 @@
182184
.crumb-snippet:hover {
183185
border-color: var(--vscode-focusBorder);
184186
box-shadow: 0 0 0 1px var(--vscode-focusBorder);
185-
}
187+
}

src/webviews/assets/breadcrumbs.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@
3737
vscode.postMessage({ type: 'createTrail' });
3838
});
3939

40-
addButton.addEventListener('click', () => {
41-
vscode.postMessage({ type: 'addCrumb' });
42-
});
40+
if (addButton) {
41+
addButton.remove();
42+
}
4343

4444
exportButton.addEventListener('click', () => {
4545
vscode.postMessage({ type: 'exportTrail' });

src/webviews/breadcrumbs/breadcrumbsWebview.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -259,14 +259,15 @@ export class BreadcrumbsWebview implements vscode.WebviewViewProvider, vscode.Di
259259
</head>
260260
<body>
261261
<section class="breadcrumbs-header">
262-
<div>
263-
<h2 class="breadcrumbs-title">Breadcrumb trails</h2>
264-
<p class="breadcrumbs-subtitle">Visualise how you navigated complex features.</p>
262+
<!--
263+
<div>
264+
<h2 class="breadcrumbs-title">Breadcrumbs</h2>
265+
<p class="breadcrumbs-subtitle">Use this feature to track complex implementations throughout different source code files. Start by creating a Trail, and then add crumbs to code snippets as you dig deeper into an implementation.</p>
265266
</div>
267+
-->
266268
<div class="breadcrumbs-actions">
267-
<button class="breadcrumbs-button" data-action="create">New trail</button>
268-
<button class="breadcrumbs-button" data-action="add">Add crumb</button>
269-
<button class="breadcrumbs-button" data-action="export">Export</button>
269+
<button class="breadcrumbs-button" data-action="create">New Trail</button>
270+
<button class="breadcrumbs-button" data-action="export">Export Trail</button>
270271
</div>
271272
</section>
272273
<section>

0 commit comments

Comments
 (0)