-
Notifications
You must be signed in to change notification settings - Fork 7
/
Cookie.java
43 lines (35 loc) · 1.21 KB
/
Cookie.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package burp;
class Cookie {
public String name;
public String sameSite;
public boolean issue = false;
public Cookie(String setCookie) {
String name;
name = setCookie.substring(0, setCookie.indexOf("="));
this.name = name;
// Iterate on cookie flag delimiters
for (String flag : setCookie.split(";")) {
flag = flag.replaceAll("\\s+", "");
flag = flag.toLowerCase();
// only parse flags with `key=val' notation
int equalDelimiter = flag.indexOf("=");
if (equalDelimiter != -1) {
String key_name = flag.substring(0, equalDelimiter);
String key_val = flag.substring(equalDelimiter + 1, flag.length());
if (key_name.equals("samesite")) {
switch(key_val) {
case "lax":
case "strict":
break;
case "none":
this.sameSite = "none";
this.issue = true;
}
return;
}
}
}
this.sameSite = "missing";
this.issue = true;
}
}