Skip to content

Commit 7383e4f

Browse files
committed
Rust: Test for another edge cases supported by two of the libraries.
1 parent 21274d3 commit 7383e4f

File tree

3 files changed

+105
-67
lines changed

3 files changed

+105
-67
lines changed

rust/ql/test/query-tests/security/CWE-614/CookieSet.expected

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,14 @@
5959
| main.rs:205:5:205:39 | ...::build(...) | secure | true |
6060
| main.rs:208:5:208:11 | [SSA] cookie2 | secure | true |
6161
| main.rs:208:5:208:11 | cookie2 | secure | true |
62-
| main.rs:255:5:255:43 | ...::build(...) | secure | false |
63-
| main.rs:256:5:256:43 | ...::build(...) | secure | false |
64-
| main.rs:259:5:259:11 | [SSA] cookie1 | secure | false |
65-
| main.rs:259:5:259:11 | cookie1 | secure | false |
66-
| main.rs:263:5:263:43 | ...::build(...) | secure | true |
67-
| main.rs:266:5:266:11 | [SSA] cookie2 | secure | true |
68-
| main.rs:266:5:266:11 | cookie2 | secure | true |
62+
| main.rs:218:5:218:11 | [SSA] cookie2 | secure | false |
63+
| main.rs:218:5:218:11 | cookie2 | secure | false |
64+
| main.rs:259:5:259:43 | ...::build(...) | secure | false |
65+
| main.rs:260:5:260:43 | ...::build(...) | secure | false |
66+
| main.rs:263:5:263:11 | [SSA] cookie1 | secure | false |
67+
| main.rs:263:5:263:11 | cookie1 | secure | false |
68+
| main.rs:267:5:267:43 | ...::build(...) | secure | true |
69+
| main.rs:270:5:270:11 | [SSA] cookie2 | secure | true |
70+
| main.rs:270:5:270:11 | cookie2 | secure | true |
71+
| main.rs:280:5:280:11 | [SSA] cookie2 | secure | false |
72+
| main.rs:280:5:280:11 | cookie2 | secure | false |

rust/ql/test/query-tests/security/CWE-614/InsecureCookie.expected

Lines changed: 86 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,19 @@
8787
| main.rs:202:9:202:11 | add | main.rs:201:5:201:11 | cookie1 | main.rs:202:9:202:11 | add | Cookie attribute 'Secure' is not set to true. |
8888
| main.rs:212:41:212:46 | finish | main.rs:212:5:212:22 | ...::build | main.rs:212:41:212:46 | finish | Cookie attribute 'Secure' is not set to true. |
8989
| main.rs:215:9:215:11 | add | main.rs:214:19:214:34 | ...::new | main.rs:215:9:215:11 | add | Cookie attribute 'Secure' is not set to true. |
90-
| main.rs:255:59:255:64 | finish | main.rs:255:5:255:26 | ...::build | main.rs:255:59:255:64 | finish | Cookie attribute 'Secure' is not set to true. |
91-
| main.rs:255:59:255:64 | finish | main.rs:255:5:255:43 | ...::build(...) | main.rs:255:59:255:64 | finish | Cookie attribute 'Secure' is not set to true. |
92-
| main.rs:256:69:256:74 | finish | main.rs:256:5:256:26 | ...::build | main.rs:256:69:256:74 | finish | Cookie attribute 'Secure' is not set to true. |
93-
| main.rs:256:69:256:74 | finish | main.rs:256:5:256:43 | ...::build(...) | main.rs:256:69:256:74 | finish | Cookie attribute 'Secure' is not set to true. |
94-
| main.rs:260:9:260:11 | add | main.rs:258:23:258:42 | ...::new | main.rs:260:9:260:11 | add | Cookie attribute 'Secure' is not set to true. |
95-
| main.rs:260:9:260:11 | add | main.rs:259:5:259:11 | [SSA] cookie1 | main.rs:260:9:260:11 | add | Cookie attribute 'Secure' is not set to true. |
96-
| main.rs:260:9:260:11 | add | main.rs:259:5:259:11 | cookie1 | main.rs:260:9:260:11 | add | Cookie attribute 'Secure' is not set to true. |
97-
| main.rs:270:45:270:50 | finish | main.rs:270:5:270:26 | ...::build | main.rs:270:45:270:50 | finish | Cookie attribute 'Secure' is not set to true. |
98-
| main.rs:273:9:273:11 | add | main.rs:272:19:272:38 | ...::new | main.rs:273:9:273:11 | add | Cookie attribute 'Secure' is not set to true. |
90+
| main.rs:219:9:219:11 | add | main.rs:218:5:218:11 | [SSA] cookie2 | main.rs:219:9:219:11 | add | Cookie attribute 'Secure' is not set to true. |
91+
| main.rs:219:9:219:11 | add | main.rs:218:5:218:11 | cookie2 | main.rs:219:9:219:11 | add | Cookie attribute 'Secure' is not set to true. |
92+
| main.rs:259:59:259:64 | finish | main.rs:259:5:259:26 | ...::build | main.rs:259:59:259:64 | finish | Cookie attribute 'Secure' is not set to true. |
93+
| main.rs:259:59:259:64 | finish | main.rs:259:5:259:43 | ...::build(...) | main.rs:259:59:259:64 | finish | Cookie attribute 'Secure' is not set to true. |
94+
| main.rs:260:69:260:74 | finish | main.rs:260:5:260:26 | ...::build | main.rs:260:69:260:74 | finish | Cookie attribute 'Secure' is not set to true. |
95+
| main.rs:260:69:260:74 | finish | main.rs:260:5:260:43 | ...::build(...) | main.rs:260:69:260:74 | finish | Cookie attribute 'Secure' is not set to true. |
96+
| main.rs:264:9:264:11 | add | main.rs:262:23:262:42 | ...::new | main.rs:264:9:264:11 | add | Cookie attribute 'Secure' is not set to true. |
97+
| main.rs:264:9:264:11 | add | main.rs:263:5:263:11 | [SSA] cookie1 | main.rs:264:9:264:11 | add | Cookie attribute 'Secure' is not set to true. |
98+
| main.rs:264:9:264:11 | add | main.rs:263:5:263:11 | cookie1 | main.rs:264:9:264:11 | add | Cookie attribute 'Secure' is not set to true. |
99+
| main.rs:274:45:274:50 | finish | main.rs:274:5:274:26 | ...::build | main.rs:274:45:274:50 | finish | Cookie attribute 'Secure' is not set to true. |
100+
| main.rs:277:9:277:11 | add | main.rs:276:19:276:38 | ...::new | main.rs:277:9:277:11 | add | Cookie attribute 'Secure' is not set to true. |
101+
| main.rs:281:9:281:11 | add | main.rs:280:5:280:11 | [SSA] cookie2 | main.rs:281:9:281:11 | add | Cookie attribute 'Secure' is not set to true. |
102+
| main.rs:281:9:281:11 | add | main.rs:280:5:280:11 | cookie2 | main.rs:281:9:281:11 | add | Cookie attribute 'Secure' is not set to true. |
99103
edges
100104
| main.rs:8:19:8:31 | ...::build | main.rs:8:19:8:50 | ...::build(...) | provenance | Src:MaD:13 MaD:13 |
101105
| main.rs:8:19:8:50 | ...::build(...) | main.rs:8:19:8:64 | ... .secure(...) | provenance | MaD:41 |
@@ -357,31 +361,43 @@ edges
357361
| main.rs:214:19:214:51 | ...::new(...) | main.rs:214:9:214:15 | cookie3 | provenance | |
358362
| main.rs:215:13:215:19 | cookie3 | main.rs:215:13:215:27 | cookie3.clone() | provenance | MaD:17 |
359363
| main.rs:215:13:215:27 | cookie3.clone() | main.rs:215:9:215:11 | add | provenance | MaD:4 Sink:MaD:4 |
360-
| main.rs:255:5:255:26 | ...::build | main.rs:255:5:255:43 | ...::build(...) | provenance | Src:MaD:13 MaD:13 |
361-
| main.rs:255:5:255:43 | ...::build(...) | main.rs:255:5:255:57 | ... .secure(...) | provenance | MaD:41 |
362-
| main.rs:255:5:255:57 | ... .secure(...) | main.rs:255:59:255:64 | finish | provenance | MaD:3 Sink:MaD:3 |
363-
| main.rs:256:5:256:26 | ...::build | main.rs:256:5:256:43 | ...::build(...) | provenance | Src:MaD:13 MaD:13 |
364-
| main.rs:256:5:256:43 | ...::build(...) | main.rs:256:5:256:57 | ... .secure(...) | provenance | MaD:41 |
365-
| main.rs:256:5:256:57 | ... .secure(...) | main.rs:256:5:256:67 | ... .path(...) | provenance | MaD:37 |
366-
| main.rs:256:5:256:67 | ... .path(...) | main.rs:256:69:256:74 | finish | provenance | MaD:3 Sink:MaD:3 |
367-
| main.rs:258:9:258:19 | mut cookie1 | main.rs:260:13:260:19 | cookie1 | provenance | |
368-
| main.rs:258:9:258:19 | mut cookie1 | main.rs:260:13:260:27 | cookie1.clone() | provenance | MaD:17 |
369-
| main.rs:258:23:258:42 | ...::new | main.rs:258:23:258:59 | ...::new(...) | provenance | Src:MaD:15 MaD:15 |
370-
| main.rs:258:23:258:59 | ...::new(...) | main.rs:258:9:258:19 | mut cookie1 | provenance | |
371-
| main.rs:259:5:259:11 | [SSA] cookie1 | main.rs:260:13:260:19 | cookie1 | provenance | |
372-
| main.rs:259:5:259:11 | [SSA] cookie1 | main.rs:260:13:260:27 | cookie1.clone() | provenance | MaD:17 |
373-
| main.rs:259:5:259:11 | cookie1 | main.rs:260:13:260:19 | cookie1 | provenance | |
374-
| main.rs:259:5:259:11 | cookie1 | main.rs:260:13:260:27 | cookie1.clone() | provenance | MaD:17 |
375-
| main.rs:260:13:260:19 | cookie1 | main.rs:260:13:260:27 | cookie1.clone() | provenance | MaD:17 |
376-
| main.rs:260:13:260:27 | cookie1.clone() | main.rs:260:9:260:11 | add | provenance | MaD:4 Sink:MaD:4 |
377-
| main.rs:270:5:270:26 | ...::build | main.rs:270:5:270:43 | ...::build(...) | provenance | Src:MaD:13 MaD:13 |
378-
| main.rs:270:5:270:43 | ...::build(...) | main.rs:270:45:270:50 | finish | provenance | MaD:3 Sink:MaD:3 |
379-
| main.rs:272:9:272:15 | cookie3 | main.rs:273:13:273:19 | cookie3 | provenance | |
380-
| main.rs:272:9:272:15 | cookie3 | main.rs:273:13:273:27 | cookie3.clone() | provenance | MaD:17 |
381-
| main.rs:272:19:272:38 | ...::new | main.rs:272:19:272:55 | ...::new(...) | provenance | Src:MaD:15 MaD:15 |
382-
| main.rs:272:19:272:55 | ...::new(...) | main.rs:272:9:272:15 | cookie3 | provenance | |
383-
| main.rs:273:13:273:19 | cookie3 | main.rs:273:13:273:27 | cookie3.clone() | provenance | MaD:17 |
384-
| main.rs:273:13:273:27 | cookie3.clone() | main.rs:273:9:273:11 | add | provenance | MaD:4 Sink:MaD:4 |
364+
| main.rs:218:5:218:11 | [SSA] cookie2 | main.rs:219:13:219:19 | cookie2 | provenance | |
365+
| main.rs:218:5:218:11 | [SSA] cookie2 | main.rs:219:13:219:27 | cookie2.clone() | provenance | MaD:17 |
366+
| main.rs:218:5:218:11 | cookie2 | main.rs:219:13:219:19 | cookie2 | provenance | |
367+
| main.rs:218:5:218:11 | cookie2 | main.rs:219:13:219:27 | cookie2.clone() | provenance | MaD:17 |
368+
| main.rs:219:13:219:19 | cookie2 | main.rs:219:13:219:27 | cookie2.clone() | provenance | MaD:17 |
369+
| main.rs:219:13:219:27 | cookie2.clone() | main.rs:219:9:219:11 | add | provenance | MaD:4 Sink:MaD:4 |
370+
| main.rs:259:5:259:26 | ...::build | main.rs:259:5:259:43 | ...::build(...) | provenance | Src:MaD:13 MaD:13 |
371+
| main.rs:259:5:259:43 | ...::build(...) | main.rs:259:5:259:57 | ... .secure(...) | provenance | MaD:41 |
372+
| main.rs:259:5:259:57 | ... .secure(...) | main.rs:259:59:259:64 | finish | provenance | MaD:3 Sink:MaD:3 |
373+
| main.rs:260:5:260:26 | ...::build | main.rs:260:5:260:43 | ...::build(...) | provenance | Src:MaD:13 MaD:13 |
374+
| main.rs:260:5:260:43 | ...::build(...) | main.rs:260:5:260:57 | ... .secure(...) | provenance | MaD:41 |
375+
| main.rs:260:5:260:57 | ... .secure(...) | main.rs:260:5:260:67 | ... .path(...) | provenance | MaD:37 |
376+
| main.rs:260:5:260:67 | ... .path(...) | main.rs:260:69:260:74 | finish | provenance | MaD:3 Sink:MaD:3 |
377+
| main.rs:262:9:262:19 | mut cookie1 | main.rs:264:13:264:19 | cookie1 | provenance | |
378+
| main.rs:262:9:262:19 | mut cookie1 | main.rs:264:13:264:27 | cookie1.clone() | provenance | MaD:17 |
379+
| main.rs:262:23:262:42 | ...::new | main.rs:262:23:262:59 | ...::new(...) | provenance | Src:MaD:15 MaD:15 |
380+
| main.rs:262:23:262:59 | ...::new(...) | main.rs:262:9:262:19 | mut cookie1 | provenance | |
381+
| main.rs:263:5:263:11 | [SSA] cookie1 | main.rs:264:13:264:19 | cookie1 | provenance | |
382+
| main.rs:263:5:263:11 | [SSA] cookie1 | main.rs:264:13:264:27 | cookie1.clone() | provenance | MaD:17 |
383+
| main.rs:263:5:263:11 | cookie1 | main.rs:264:13:264:19 | cookie1 | provenance | |
384+
| main.rs:263:5:263:11 | cookie1 | main.rs:264:13:264:27 | cookie1.clone() | provenance | MaD:17 |
385+
| main.rs:264:13:264:19 | cookie1 | main.rs:264:13:264:27 | cookie1.clone() | provenance | MaD:17 |
386+
| main.rs:264:13:264:27 | cookie1.clone() | main.rs:264:9:264:11 | add | provenance | MaD:4 Sink:MaD:4 |
387+
| main.rs:274:5:274:26 | ...::build | main.rs:274:5:274:43 | ...::build(...) | provenance | Src:MaD:13 MaD:13 |
388+
| main.rs:274:5:274:43 | ...::build(...) | main.rs:274:45:274:50 | finish | provenance | MaD:3 Sink:MaD:3 |
389+
| main.rs:276:9:276:15 | cookie3 | main.rs:277:13:277:19 | cookie3 | provenance | |
390+
| main.rs:276:9:276:15 | cookie3 | main.rs:277:13:277:27 | cookie3.clone() | provenance | MaD:17 |
391+
| main.rs:276:19:276:38 | ...::new | main.rs:276:19:276:55 | ...::new(...) | provenance | Src:MaD:15 MaD:15 |
392+
| main.rs:276:19:276:55 | ...::new(...) | main.rs:276:9:276:15 | cookie3 | provenance | |
393+
| main.rs:277:13:277:19 | cookie3 | main.rs:277:13:277:27 | cookie3.clone() | provenance | MaD:17 |
394+
| main.rs:277:13:277:27 | cookie3.clone() | main.rs:277:9:277:11 | add | provenance | MaD:4 Sink:MaD:4 |
395+
| main.rs:280:5:280:11 | [SSA] cookie2 | main.rs:281:13:281:19 | cookie2 | provenance | |
396+
| main.rs:280:5:280:11 | [SSA] cookie2 | main.rs:281:13:281:27 | cookie2.clone() | provenance | MaD:17 |
397+
| main.rs:280:5:280:11 | cookie2 | main.rs:281:13:281:19 | cookie2 | provenance | |
398+
| main.rs:280:5:280:11 | cookie2 | main.rs:281:13:281:27 | cookie2.clone() | provenance | MaD:17 |
399+
| main.rs:281:13:281:19 | cookie2 | main.rs:281:13:281:27 | cookie2.clone() | provenance | MaD:17 |
400+
| main.rs:281:13:281:27 | cookie2.clone() | main.rs:281:9:281:11 | add | provenance | MaD:4 Sink:MaD:4 |
385401
models
386402
| 1 | Sink: <biscotti::response_cookies::ResponseCookies>::insert; Argument[0]; cookie-use |
387403
| 2 | Sink: <cookie::builder::CookieBuilder>::build; Argument[self]; cookie-use |
@@ -688,30 +704,40 @@ nodes
688704
| main.rs:215:9:215:11 | add | semmle.label | add |
689705
| main.rs:215:13:215:19 | cookie3 | semmle.label | cookie3 |
690706
| main.rs:215:13:215:27 | cookie3.clone() | semmle.label | cookie3.clone() |
691-
| main.rs:255:5:255:26 | ...::build | semmle.label | ...::build |
692-
| main.rs:255:5:255:43 | ...::build(...) | semmle.label | ...::build(...) |
693-
| main.rs:255:5:255:57 | ... .secure(...) | semmle.label | ... .secure(...) |
694-
| main.rs:255:59:255:64 | finish | semmle.label | finish |
695-
| main.rs:256:5:256:26 | ...::build | semmle.label | ...::build |
696-
| main.rs:256:5:256:43 | ...::build(...) | semmle.label | ...::build(...) |
697-
| main.rs:256:5:256:57 | ... .secure(...) | semmle.label | ... .secure(...) |
698-
| main.rs:256:5:256:67 | ... .path(...) | semmle.label | ... .path(...) |
699-
| main.rs:256:69:256:74 | finish | semmle.label | finish |
700-
| main.rs:258:9:258:19 | mut cookie1 | semmle.label | mut cookie1 |
701-
| main.rs:258:23:258:42 | ...::new | semmle.label | ...::new |
702-
| main.rs:258:23:258:59 | ...::new(...) | semmle.label | ...::new(...) |
703-
| main.rs:259:5:259:11 | [SSA] cookie1 | semmle.label | [SSA] cookie1 |
704-
| main.rs:259:5:259:11 | cookie1 | semmle.label | cookie1 |
705-
| main.rs:260:9:260:11 | add | semmle.label | add |
706-
| main.rs:260:13:260:19 | cookie1 | semmle.label | cookie1 |
707-
| main.rs:260:13:260:27 | cookie1.clone() | semmle.label | cookie1.clone() |
708-
| main.rs:270:5:270:26 | ...::build | semmle.label | ...::build |
709-
| main.rs:270:5:270:43 | ...::build(...) | semmle.label | ...::build(...) |
710-
| main.rs:270:45:270:50 | finish | semmle.label | finish |
711-
| main.rs:272:9:272:15 | cookie3 | semmle.label | cookie3 |
712-
| main.rs:272:19:272:38 | ...::new | semmle.label | ...::new |
713-
| main.rs:272:19:272:55 | ...::new(...) | semmle.label | ...::new(...) |
714-
| main.rs:273:9:273:11 | add | semmle.label | add |
715-
| main.rs:273:13:273:19 | cookie3 | semmle.label | cookie3 |
716-
| main.rs:273:13:273:27 | cookie3.clone() | semmle.label | cookie3.clone() |
707+
| main.rs:218:5:218:11 | [SSA] cookie2 | semmle.label | [SSA] cookie2 |
708+
| main.rs:218:5:218:11 | cookie2 | semmle.label | cookie2 |
709+
| main.rs:219:9:219:11 | add | semmle.label | add |
710+
| main.rs:219:13:219:19 | cookie2 | semmle.label | cookie2 |
711+
| main.rs:219:13:219:27 | cookie2.clone() | semmle.label | cookie2.clone() |
712+
| main.rs:259:5:259:26 | ...::build | semmle.label | ...::build |
713+
| main.rs:259:5:259:43 | ...::build(...) | semmle.label | ...::build(...) |
714+
| main.rs:259:5:259:57 | ... .secure(...) | semmle.label | ... .secure(...) |
715+
| main.rs:259:59:259:64 | finish | semmle.label | finish |
716+
| main.rs:260:5:260:26 | ...::build | semmle.label | ...::build |
717+
| main.rs:260:5:260:43 | ...::build(...) | semmle.label | ...::build(...) |
718+
| main.rs:260:5:260:57 | ... .secure(...) | semmle.label | ... .secure(...) |
719+
| main.rs:260:5:260:67 | ... .path(...) | semmle.label | ... .path(...) |
720+
| main.rs:260:69:260:74 | finish | semmle.label | finish |
721+
| main.rs:262:9:262:19 | mut cookie1 | semmle.label | mut cookie1 |
722+
| main.rs:262:23:262:42 | ...::new | semmle.label | ...::new |
723+
| main.rs:262:23:262:59 | ...::new(...) | semmle.label | ...::new(...) |
724+
| main.rs:263:5:263:11 | [SSA] cookie1 | semmle.label | [SSA] cookie1 |
725+
| main.rs:263:5:263:11 | cookie1 | semmle.label | cookie1 |
726+
| main.rs:264:9:264:11 | add | semmle.label | add |
727+
| main.rs:264:13:264:19 | cookie1 | semmle.label | cookie1 |
728+
| main.rs:264:13:264:27 | cookie1.clone() | semmle.label | cookie1.clone() |
729+
| main.rs:274:5:274:26 | ...::build | semmle.label | ...::build |
730+
| main.rs:274:5:274:43 | ...::build(...) | semmle.label | ...::build(...) |
731+
| main.rs:274:45:274:50 | finish | semmle.label | finish |
732+
| main.rs:276:9:276:15 | cookie3 | semmle.label | cookie3 |
733+
| main.rs:276:19:276:38 | ...::new | semmle.label | ...::new |
734+
| main.rs:276:19:276:55 | ...::new(...) | semmle.label | ...::new(...) |
735+
| main.rs:277:9:277:11 | add | semmle.label | add |
736+
| main.rs:277:13:277:19 | cookie3 | semmle.label | cookie3 |
737+
| main.rs:277:13:277:27 | cookie3.clone() | semmle.label | cookie3.clone() |
738+
| main.rs:280:5:280:11 | [SSA] cookie2 | semmle.label | [SSA] cookie2 |
739+
| main.rs:280:5:280:11 | cookie2 | semmle.label | cookie2 |
740+
| main.rs:281:9:281:11 | add | semmle.label | add |
741+
| main.rs:281:13:281:19 | cookie2 | semmle.label | cookie2 |
742+
| main.rs:281:13:281:27 | cookie2.clone() | semmle.label | cookie2.clone() |
717743
subpaths

rust/ql/test/query-tests/security/CWE-614/main.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,10 @@ fn test_actix_web() {
213213

214214
let cookie3 = ActixCookie::new("name", "value"); // $ Source
215215
jar.add(cookie3.clone()); // $ Alert[rust/insecure-cookie]
216+
217+
// secure reset to None
218+
cookie2.set_secure(None); // $ Source
219+
jar.add(cookie2.clone()); // $ Alert[rust/insecure-cookie]
216220
}
217221

218222
fn test_poem() {
@@ -271,6 +275,10 @@ fn test_http_types() {
271275

272276
let cookie3 = HttpTypesCookie::new("name", "value"); // $ Source
273277
jar.add(cookie3.clone()); // $ Alert[rust/insecure-cookie]
278+
279+
// secure reset to None
280+
cookie2.set_secure(None); // $ Source
281+
jar.add(cookie2.clone()); // $ Alert[rust/insecure-cookie]
274282
}
275283

276284
fn main() {

0 commit comments

Comments
 (0)