@@ -29,24 +29,39 @@ import experimental.semmle.python.Concepts
29
29
class CookieHeader extends Cookie:: Range instanceof HeaderDeclaration {
30
30
CookieHeader ( ) {
31
31
this instanceof HeaderDeclaration and
32
- this .( HeaderDeclaration ) .getNameArg ( ) .asExpr ( ) .( Str_ ) .getS ( ) = "Set-Cookie"
32
+ exists ( StrConst str |
33
+ str .getText ( ) = "Set-Cookie" and
34
+ DataFlow:: exprNode ( str )
35
+ .( DataFlow:: LocalSourceNode )
36
+ .flowsTo ( this .( HeaderDeclaration ) .getNameArg ( ) )
37
+ )
33
38
}
34
39
35
40
override predicate isSecure ( ) {
36
- this .( HeaderDeclaration ) .getValueArg ( ) .asExpr ( ) .( Str_ ) .getS ( ) .regexpMatch ( ".*; *Secure;.*" )
41
+ exists ( StrConst str |
42
+ str .getText ( ) .regexpMatch ( ".*; *Secure;.*" ) and
43
+ DataFlow:: exprNode ( str )
44
+ .( DataFlow:: LocalSourceNode )
45
+ .flowsTo ( this .( HeaderDeclaration ) .getValueArg ( ) )
46
+ )
37
47
}
38
48
39
49
override predicate isHttpOnly ( ) {
40
- this .( HeaderDeclaration ) .getValueArg ( ) .asExpr ( ) .( Str_ ) .getS ( ) .regexpMatch ( ".*; *HttpOnly;.*" )
50
+ exists ( StrConst str |
51
+ str .getText ( ) .regexpMatch ( ".*; *HttpOnly;.*" ) and
52
+ DataFlow:: exprNode ( str )
53
+ .( DataFlow:: LocalSourceNode )
54
+ .flowsTo ( this .( HeaderDeclaration ) .getValueArg ( ) )
55
+ )
41
56
}
42
57
43
58
override predicate isSameSite ( ) {
44
- this . ( HeaderDeclaration )
45
- . getValueArg ( )
46
- . asExpr ( )
47
- . ( Str_ )
48
- . getS ( )
49
- . regexpMatch ( ".*; *SameSite=(Strict|Lax);.*" )
59
+ exists ( StrConst str |
60
+ str . getText ( ) . regexpMatch ( ".*; *SameSite=(Strict|Lax);.*" ) and
61
+ DataFlow :: exprNode ( str )
62
+ . ( DataFlow :: LocalSourceNode )
63
+ . flowsTo ( this . ( HeaderDeclaration ) . getValueArg ( ) )
64
+ )
50
65
}
51
66
52
67
override DataFlow:: Node getNameArg ( ) { result = this .( HeaderDeclaration ) .getValueArg ( ) }
0 commit comments