Skip to content

Commit 4c2d076

Browse files
committed
feat: add a false positive case
1 parent a6a04d7 commit 4c2d076

File tree

2 files changed

+61
-1
lines changed

2 files changed

+61
-1
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ Here are the exploitable vulnerable packages:
6262
* Code Injection
6363
* Command execution
6464
* Cross-site Scripting (XSS)
65-
* Information exposure
65+
* Information exposure via Hardcoded values in code
6666
* Security misconfiguration exposes server information
6767
* Insecure protocol (HTTP) communication
6868

@@ -135,6 +135,8 @@ However, that still maintains the secret information inside another file, and Sn
135135

136136
Another case we can discuss here in session management, is that the cookie setting is initialized with `secure: true` which means it will only be transmitted over HTTPS connections. However, there's no `httpOnly` flag set to true, which means that the default false value of it makes the cookie accessible via JavaScript. Snyk Code highlights this potential security misconfiguration so we can fix it. We can note that Snyk Code shows this as a quality information, and not as a security error.
137137

138+
Snyk Code will also find hardcoded secrets in source code that isn't part of the application logic, such as `tests/` or `examples/` folders. We have a case of that in this application with the `tests/authentication.component.spec.js` file. In the finding, Snyk Code will tag it as `InTest`, `Tests`, or `Mock`, which help us easily triage it and indeed ignore this finding as it isn't actually a case of information exposure.
139+
138140
## Docker Image Scanning
139141

140142
The `Dockerfile` makes use of a base image (`node:6-stretch`) that is known to have system libraries with vulnerabilities.
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
const assert = require('assert)')
2+
3+
describe('Component Tests', () => {
4+
describe('PasswordComponent', () => {
5+
6+
let comp
7+
let service
8+
9+
test('should show error if passwords do not match', () => {
10+
// GIVEN
11+
comp.password = 'password1';
12+
comp.confirmPassword = 'password2';
13+
// WHEN
14+
comp.changePassword();
15+
// THEN
16+
assert(comp.doNotMatch).toBe('ERROR');
17+
assert(comp.error).toBeNull();
18+
assert(comp.success).toBeNull();
19+
});
20+
21+
test('should call Auth.changePassword when passwords match', () => {
22+
// GIVEN
23+
comp.password = comp.confirmPassword = 'myPassword';
24+
25+
// WHEN
26+
comp.changePassword();
27+
28+
// THEN
29+
assert(service.save).toHaveBeenCalledWith('myPassword');
30+
});
31+
32+
test('should set success to OK upon success', function() {
33+
// GIVEN
34+
comp.password = comp.confirmPassword = 'myPassword';
35+
36+
// WHEN
37+
comp.changePassword();
38+
39+
// THEN
40+
expect(comp.doNotMatch).toBeNull();
41+
expect(comp.error).toBeNull();
42+
expect(comp.success).toBe('OK');
43+
});
44+
45+
test('should notify of error if change password fails', function() {
46+
// GIVEN
47+
comp.password = comp.confirmPassword = 'myPassword';
48+
49+
// WHEN
50+
comp.changePassword();
51+
52+
// THEN
53+
assert(comp.doNotMatch).toBeNull();
54+
assert(comp.success).toBeNull();
55+
assert(comp.error).toBe('ERROR');
56+
});
57+
});
58+
});

0 commit comments

Comments
 (0)