Skip to content

Commit 0976dd3

Browse files
Rewrie some simple IPA types
1 parent 7ddc8f0 commit 0976dd3

File tree

3 files changed

+21
-34
lines changed

3 files changed

+21
-34
lines changed

python/ql/lib/semmle/python/Concepts.qll

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1419,29 +1419,24 @@ module Http {
14191419
}
14201420
}
14211421

1422-
private newtype TSameSiteValue =
1423-
TSameSiteStrict() or
1424-
TSameSiteLax() or
1425-
TSameSiteNone()
1426-
14271422
/** A possible value for the SameSite attribute of a cookie. */
1428-
class SameSiteValue extends TSameSiteValue {
1423+
abstract new class SameSiteValue {
14291424
/** Gets a string representation of this value. */
1430-
string toString() { none() }
1425+
abstract string toString();
14311426
}
14321427

14331428
/** A `Strict` value of the `SameSite` attribute. */
1434-
class SameSiteStrict extends SameSiteValue, TSameSiteStrict {
1429+
final new class SameSiteStrict extends SameSiteValue {
14351430
override string toString() { result = "Strict" }
14361431
}
14371432

14381433
/** A `Lax` value of the `SameSite` attribute. */
1439-
class SameSiteLax extends SameSiteValue, TSameSiteLax {
1434+
final new class SameSiteLax extends SameSiteValue {
14401435
override string toString() { result = "Lax" }
14411436
}
14421437

14431438
/** A `None` value of the `SameSite` attribute. */
1444-
class SameSiteNone extends SameSiteValue, TSameSiteNone {
1439+
final new class SameSiteNone extends SameSiteValue {
14451440
override string toString() { result = "None" }
14461441
}
14471442
}

ruby/ql/lib/codeql/ruby/security/CodeInjectionCustomizations.qll

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,8 @@ module CodeInjection {
2626
*/
2727
deprecated DataFlow::FlowState full() { result = "full" }
2828

29-
private newtype TState =
30-
TFull() or
31-
TSubString()
32-
3329
/** A flow state used to distinguish whether an attacker controls the entire string. */
34-
class State extends TState {
30+
abstract new class State {
3531
/**
3632
* Gets a string representation of this state.
3733
*/
@@ -40,22 +36,22 @@ module CodeInjection {
4036
/**
4137
* Gets a canonical string representation of this state.
4238
*/
43-
string getStringRepresentation() {
44-
this = TSubString() and result = "substring"
45-
or
46-
this = TFull() and result = "full"
47-
}
39+
abstract string getStringRepresentation();
4840
}
4941

5042
/**
5143
* A flow state used for normal tainted data, where an attacker might only control a substring.
5244
*/
53-
class SubString extends State, TSubString { }
45+
final new class SubString extends State {
46+
override string getStringRepresentation() { result = "substring" }
47+
}
5448

5549
/**
5650
* A flow state used for data that is entirely controlled by the attacker.
5751
*/
58-
class Full extends State, TFull { }
52+
final new class Full extends State {
53+
override string getStringRepresentation() { result = "full" }
54+
}
5955
}
6056

6157
/**

ruby/ql/lib/codeql/ruby/security/MassAssignmentQuery.qll

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,20 @@ private import codeql.ruby.dataflow.RemoteFlowSources
99
private import MassAssignmentCustomizations
1010

1111
private module FlowState {
12-
private newtype TState =
13-
TUnpermitted() or
14-
TPermitted()
15-
1612
/** A flow state used to distinguish whether arbitrary user parameters have been permitted to be used for mass assignment. */
17-
class State extends TState {
18-
string toString() {
19-
this = TUnpermitted() and result = "unpermitted"
20-
or
21-
this = TPermitted() and result = "permitted"
22-
}
13+
abstract new class State {
14+
abstract string toString();
2315
}
2416

2517
/** A flow state used for user parameters for which arbitrary parameters have not been permitted to use for mass assignment. */
26-
class Unpermitted extends State, TUnpermitted { }
18+
final new class Unpermitted extends State {
19+
override string toString() { result = "unpermitted" }
20+
}
2721

2822
/** A flow state used for user parameters for which arbitrary parameters have been permitted to use for mass assignment. */
29-
class Permitted extends State, TPermitted { }
23+
final new class Permitted extends State {
24+
override string toString() { result = "permitted" }
25+
}
3026
}
3127

3228
/** A flow configuration for reasoning about insecure mass assignment. */

0 commit comments

Comments
 (0)