Skip to content

Commit 4e0b949

Browse files
committed
support/crate-report-form: Add vulnerability reporting help text
1 parent 38ab486 commit 4e0b949

File tree

4 files changed

+76
-11
lines changed

4 files changed

+76
-11
lines changed

app/components/support/crate-report-form.css

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,22 @@
6262
}
6363
}
6464

65+
.vulnerability-report {
66+
padding: var(--space-s) var(--space-s);
67+
background-color: light-dark(white, #141413);
68+
border: 1px solid var(--gray-border);
69+
border-radius: var(--space-3xs);
70+
width: 100%;
71+
72+
:first-child {
73+
margin-top: 0;
74+
}
75+
76+
:last-child {
77+
margin-bottom: 0;
78+
}
79+
}
80+
6581
.buttons {
6682
position: relative;
6783
margin: var(--space-m) 0;

app/components/support/crate-report-form.gjs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Input, Textarea } from '@ember/component';
22
import { fn, uniqueId } from '@ember/helper';
33
import { on } from '@ember/modifier';
44
import { action } from '@ember/object';
5+
import { LinkTo } from '@ember/routing';
56
import { service } from '@ember/service';
67
import Component from '@glimmer/component';
78
import { tracked } from '@glimmer/tracking';
@@ -29,7 +30,7 @@ const REASONS = [
2930
},
3031
{
3132
reason: 'vulnerability',
32-
description: 'it contains a vulnerability (please try to contact the crate author first)',
33+
description: 'it contains a vulnerability',
3334
},
3435
{
3536
reason: 'other',
@@ -84,6 +85,10 @@ export default class CrateReportForm extends Component {
8485
return this.selectedReasons.includes('malicious-code');
8586
}
8687

88+
get isVulnerabilityReport() {
89+
return this.selectedReasons.includes('vulnerability');
90+
}
91+
8792
@action
8893
submit() {
8994
if (!this.validate()) {
@@ -182,6 +187,20 @@ ${this.detail}
182187
{{/if}}
183188
</fieldset>
184189

190+
{{#if this.isVulnerabilityReport}}
191+
<div class='vulnerability-report form-group' data-test-id='vulnerability-report'>
192+
<h3>🔍 Vulnerability Report</h3>
193+
<p>For crate vulnerabilities, please consider:</p>
194+
<ul>
195+
<li>Contacting the crate author first when possible</li>
196+
<li>Reporting to the
197+
<a href='https://rustsec.org/contributing.html' target='_blank' rel='noopener noreferrer'>RustSec Advisory
198+
Database</a></li>
199+
<li>Reviewing our <LinkTo @route='policies.security' target='_blank'>security policy</LinkTo></li>
200+
</ul>
201+
</div>
202+
{{/if}}
203+
185204
<fieldset class='form-group' data-test-id='fieldset-detail'>
186205
{{#let (uniqueId) as |id|}}
187206
<label for={{id}} class='form-group-name'>Detail</label>

e2e/acceptance/support.spec.ts

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ test.describe('Acceptance | support page', { tag: '@acceptance' }, () => {
133133
- [ ] it is name-squatting (reserving a crate name without content)
134134
- [ ] it is abusive or otherwise harmful
135135
- [ ] it contains malicious code
136-
- [ ] it contains a vulnerability (please try to contact the crate author first)
136+
- [ ] it contains a vulnerability
137137
- [ ] it is violating the usage policy in some other way (please specify below)
138138
139139
Additional details:
@@ -178,7 +178,7 @@ Additional details:
178178
- [ ] it is name-squatting (reserving a crate name without content)
179179
- [ ] it is abusive or otherwise harmful
180180
- [ ] it contains malicious code
181-
- [ ] it contains a vulnerability (please try to contact the crate author first)
181+
- [ ] it contains a vulnerability
182182
- [x] it is violating the usage policy in some other way (please specify below)
183183
184184
Additional details:
@@ -257,7 +257,7 @@ test detail
257257
- [ ] it is name-squatting (reserving a crate name without content)
258258
- [ ] it is abusive or otherwise harmful
259259
- [ ] it contains malicious code
260-
- [ ] it contains a vulnerability (please try to contact the crate author first)
260+
- [ ] it contains a vulnerability
261261
- [ ] it is violating the usage policy in some other way (please specify below)
262262
263263
Additional details:
@@ -298,7 +298,7 @@ Additional details:
298298
- [ ] it is name-squatting (reserving a crate name without content)
299299
- [ ] it is abusive or otherwise harmful
300300
- [ ] it contains malicious code
301-
- [ ] it contains a vulnerability (please try to contact the crate author first)
301+
- [ ] it contains a vulnerability
302302
- [x] it is violating the usage policy in some other way (please specify below)
303303
304304
Additional details:
@@ -344,7 +344,7 @@ test detail
344344
- [ ] it is name-squatting (reserving a crate name without content)
345345
- [ ] it is abusive or otherwise harmful
346346
- [x] it contains malicious code
347-
- [ ] it contains a vulnerability (please try to contact the crate author first)
347+
- [ ] it contains a vulnerability
348348
- [ ] it is violating the usage policy in some other way (please specify below)
349349
350350
Additional details:
@@ -359,4 +359,20 @@ test detail
359359
await page.waitForFunction(expect => globalThis.openKwargs.url === expect, mailto);
360360
await page.waitForFunction(expect => globalThis.openKwargs.target === expect, '_self');
361361
});
362+
363+
test('shows help text for vulnerability reports', async ({ page }) => {
364+
await page.goto('/support');
365+
await page.getByTestId('link-crate-violation').click();
366+
await expect(page).toHaveURL('/support?inquire=crate-violation');
367+
368+
const crateInput = page.getByTestId('crate-input');
369+
await crateInput.fill('nanomsg');
370+
await expect(crateInput).toHaveValue('nanomsg');
371+
await expect(page.getByTestId('vulnerability-report')).not.toBeVisible();
372+
373+
const checkbox = page.getByTestId('vulnerability-checkbox');
374+
await checkbox.check();
375+
await expect(checkbox).toBeChecked();
376+
await expect(page.getByTestId('vulnerability-report')).toBeVisible();
377+
});
362378
});

tests/acceptance/support-test.js

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ module('Acceptance | support', function (hooks) {
145145
- [ ] it is name-squatting (reserving a crate name without content)
146146
- [ ] it is abusive or otherwise harmful
147147
- [ ] it contains malicious code
148-
- [ ] it contains a vulnerability (please try to contact the crate author first)
148+
- [ ] it contains a vulnerability
149149
- [ ] it is violating the usage policy in some other way (please specify below)
150150
151151
Additional details:
@@ -183,7 +183,7 @@ Additional details:
183183
- [ ] it is name-squatting (reserving a crate name without content)
184184
- [ ] it is abusive or otherwise harmful
185185
- [ ] it contains malicious code
186-
- [ ] it contains a vulnerability (please try to contact the crate author first)
186+
- [ ] it contains a vulnerability
187187
- [x] it is violating the usage policy in some other way (please specify below)
188188
189189
Additional details:
@@ -284,7 +284,7 @@ test detail
284284
- [ ] it is name-squatting (reserving a crate name without content)
285285
- [ ] it is abusive or otherwise harmful
286286
- [ ] it contains malicious code
287-
- [ ] it contains a vulnerability (please try to contact the crate author first)
287+
- [ ] it contains a vulnerability
288288
- [ ] it is violating the usage policy in some other way (please specify below)
289289
290290
Additional details:
@@ -320,7 +320,7 @@ Additional details:
320320
- [ ] it is name-squatting (reserving a crate name without content)
321321
- [ ] it is abusive or otherwise harmful
322322
- [ ] it contains malicious code
323-
- [ ] it contains a vulnerability (please try to contact the crate author first)
323+
- [ ] it contains a vulnerability
324324
- [x] it is violating the usage policy in some other way (please specify below)
325325
326326
Additional details:
@@ -359,7 +359,7 @@ test detail
359359
- [ ] it is name-squatting (reserving a crate name without content)
360360
- [ ] it is abusive or otherwise harmful
361361
- [x] it contains malicious code
362-
- [ ] it contains a vulnerability (please try to contact the crate author first)
362+
- [ ] it contains a vulnerability
363363
- [ ] it is violating the usage policy in some other way (please specify below)
364364
365365
Additional details:
@@ -373,4 +373,18 @@ test detail
373373
assert.strictEqual(window.openKwargs.url, mailto);
374374
assert.strictEqual(window.openKwargs.target, '_self');
375375
});
376+
377+
test('shows help text for vulnerability reports', async function (assert) {
378+
await visit('/support');
379+
await click('[data-test-id="link-crate-violation"]');
380+
assert.strictEqual(currentURL(), '/support?inquire=crate-violation');
381+
382+
await fillIn('[data-test-id="crate-input"]', 'nanomsg');
383+
assert.dom('[data-test-id="crate-input"]').hasValue('nanomsg');
384+
assert.dom('[data-test-id="vulnerability-report"]').doesNotExist();
385+
386+
await click('[data-test-id="vulnerability-checkbox"]');
387+
assert.dom('[data-test-id="vulnerability-checkbox"]').isChecked();
388+
assert.dom('[data-test-id="vulnerability-report"]').exists();
389+
});
376390
});

0 commit comments

Comments
 (0)