Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 98dfe1a

Browse files
committed
Python: Elaborate qldoc and renames to match
1 parent 8155334 commit 98dfe1a

1 file changed

Lines changed: 24 additions & 10 deletions

File tree

  • python/ql/src/Security/CWE-327

python/ql/src/Security/CWE-327/Ssl.qll

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class OptionsAugOr extends ProtocolRestriction {
4545
(
4646
aa.getValue() = flag
4747
or
48-
impliesValue(aa.getValue(), flag, false, false)
48+
impliesBitSet(aa.getValue(), flag, false, false)
4949
)
5050
)
5151
}
@@ -70,7 +70,7 @@ class OptionsAugAndNot extends ProtocolUnrestriction {
7070
(
7171
aa.getValue() = notFlag
7272
or
73-
impliesValue(aa.getValue(), notFlag, true, true)
73+
impliesBitSet(aa.getValue(), notFlag, true, true)
7474
)
7575
)
7676
}
@@ -80,22 +80,36 @@ class OptionsAugAndNot extends ProtocolUnrestriction {
8080
override ProtocolVersion getUnrestriction() { result = restriction }
8181
}
8282

83-
/** Whether `part` evaluates to `partIsTrue` if `whole` evaluates to `wholeIsTrue`. */
84-
predicate impliesValue(BinaryExpr whole, Expr part, boolean partIsTrue, boolean wholeIsTrue) {
83+
/**
84+
* Holds if
85+
* for every bit, _b_:
86+
* `wholeHasBitSet` represents that _b_ is set in `whole`
87+
* implies
88+
* `partHasBitSet` represents that _b_ is set in `part`
89+
*
90+
* As an example take `whole` = `part1 & part2`. Then
91+
* `impliesBitSet(whole, part1, true, true)` holds
92+
* because for any bit in `whole`, if that bit is set it must also be set in `part1`.
93+
*
94+
* Similarly for `whole` = `part1 | part2`. Here
95+
* `impliesBitSet(whole, part1, false, false)` holds
96+
* because for any bit in `whole`, if that bit is not set, it cannot be set in `part1`.
97+
*/
98+
predicate impliesBitSet(BinaryExpr whole, Expr part, boolean partHasBitSet, boolean wholeHasBitSet) {
8599
whole.getOp() instanceof BitAnd and
86100
(
87-
wholeIsTrue = true and partIsTrue = true and part in [whole.getLeft(), whole.getRight()]
101+
wholeHasBitSet = true and partHasBitSet = true and part in [whole.getLeft(), whole.getRight()]
88102
or
89-
wholeIsTrue = true and
90-
impliesValue([whole.getLeft(), whole.getRight()], part, partIsTrue, wholeIsTrue)
103+
wholeHasBitSet = true and
104+
impliesBitSet([whole.getLeft(), whole.getRight()], part, partHasBitSet, wholeHasBitSet)
91105
)
92106
or
93107
whole.getOp() instanceof BitOr and
94108
(
95-
wholeIsTrue = false and partIsTrue = false and part in [whole.getLeft(), whole.getRight()]
109+
wholeHasBitSet = false and partHasBitSet = false and part in [whole.getLeft(), whole.getRight()]
96110
or
97-
wholeIsTrue = false and
98-
impliesValue([whole.getLeft(), whole.getRight()], part, partIsTrue, wholeIsTrue)
111+
wholeHasBitSet = false and
112+
impliesBitSet([whole.getLeft(), whole.getRight()], part, partHasBitSet, wholeHasBitSet)
99113
)
100114
}
101115

0 commit comments

Comments
 (0)