Skip to content

Commit 2521848

Browse files
Merging the scenarios.
1 parent ad4873a commit 2521848

File tree

4 files changed

+19
-27
lines changed

4 files changed

+19
-27
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,7 @@
1313
/.vs/ql/v15/Browse.VC.db
1414
/.vs/ProjectSettings.json
1515

16+
/.vs/VSWorkspaceState.json
17+
/.vs/ql_ICryptoTransformLmbda/v15/Browse.VC.opendb
18+
/.vs/ql_ICryptoTransformLmbda/v15/Browse.VC.db
19+
/.vs/ql_ICryptoTransformLmbda/v15/.suo

csharp/ql/src/Likely Bugs/ParallelSink.qll

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,13 @@ class LambdaParallelSink extends ParallelSink {
1616
)
1717
}
1818
}
19+
20+
class ThreadStartParallelSink extends ParallelSink {
21+
ThreadStartParallelSink() {
22+
exists( DelegateCreation dc, Expr e |
23+
e = this.asExpr() |
24+
dc.getArgument() = e
25+
and dc.getType().getName().matches("%Start")
26+
)
27+
}
28+
}

csharp/ql/src/Likely Bugs/ThreadUnsafeICryptoTransformLambda.ql

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,6 @@ import semmle.code.csharp.dataflow.DataFlow
1818
import ParallelSink
1919
import ICryptoTransform
2020

21-
class NotThreadSafeCryptoUsageIntoStartingCallingConfig extends TaintTracking::Configuration {
22-
NotThreadSafeCryptoUsageIntoStartingCallingConfig() { this = "NotThreadSafeCryptoUsageIntoStartingCallingConfig" }
23-
24-
override predicate isSource(DataFlow::Node source) {
25-
source instanceof LambdaCapturingICryptoTransformSource
26-
}
27-
28-
override predicate isSink(DataFlow::Node sink) {
29-
exists( DelegateCreation dc, Expr e |
30-
e = sink.asExpr() |
31-
dc.getArgument() = e
32-
and dc.getType().getName().matches("%Start")
33-
)
34-
}
35-
}
36-
3721
class NotThreadSafeCryptoUsageIntoParallelInvokeConfig extends TaintTracking::Configuration {
3822
NotThreadSafeCryptoUsageIntoParallelInvokeConfig() { this = "NotThreadSafeCryptoUsageIntoParallelInvokeConfig" }
3923

@@ -46,14 +30,8 @@ class NotThreadSafeCryptoUsageIntoParallelInvokeConfig extends TaintTracking::Co
4630
}
4731
}
4832

49-
from Expr e, string m, LambdaExpr l
33+
from Expr e, string m, LambdaExpr l, NotThreadSafeCryptoUsageIntoParallelInvokeConfig config
5034
where
51-
exists( NotThreadSafeCryptoUsageIntoParallelInvokeConfig config |
52-
config.hasFlow(DataFlow::exprNode(l), DataFlow::exprNode(e))
53-
and m = "A $@ seems to be used to start a new thread using System.Threading.Tasks.Parallel.Invoke, and is capturing a local variable that either implements 'System.Security.Cryptography.ICryptoTransform' or has a field of this type."
54-
)
55-
or exists ( NotThreadSafeCryptoUsageIntoStartingCallingConfig config |
56-
config.hasFlow(DataFlow::exprNode(l), DataFlow::exprNode(e))
57-
and m = "A $@ seems to be used to start a new thread is capturing a local variable that either implements 'System.Security.Cryptography.ICryptoTransform' or has a field of this type."
58-
)
35+
config.hasFlow(DataFlow::exprNode(l), DataFlow::exprNode(e))
36+
and m = "A $@ seems to be used to start a new thread is capturing a local variable that either implements 'System.Security.Cryptography.ICryptoTransform' or has a field of this type."
5937
select e, m, l, "lambda expression"
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
| ThreadUnsafeICryptoTransformLambda.cs:27:62:27:66 | access to local variable start | A $@ seems to be used to start a new thread is capturing a local variable that either implements 'System.Security.Cryptography.ICryptoTransform' or has a field of this type. | ThreadUnsafeICryptoTransformLambda.cs:17:24:23:9 | (...) => ... | lambda expression |
22
| ThreadUnsafeICryptoTransformLambda.cs:89:62:89:66 | access to local variable start | A $@ seems to be used to start a new thread is capturing a local variable that either implements 'System.Security.Cryptography.ICryptoTransform' or has a field of this type. | ThreadUnsafeICryptoTransformLambda.cs:81:24:87:9 | (...) => ... | lambda expression |
3-
| ThreadUnsafeICryptoTransformLambda.cs:143:29:147:17 | (...) => ... | A $@ seems to be used to start a new thread using System.Threading.Tasks.Parallel.Invoke, and is capturing a local variable that either implements 'System.Security.Cryptography.ICryptoTransform' or has a field of this type. | ThreadUnsafeICryptoTransformLambda.cs:143:29:147:17 | (...) => ... | lambda expression |
4-
| ThreadUnsafeICryptoTransformLambda.cs:148:17:152:17 | (...) => ... | A $@ seems to be used to start a new thread using System.Threading.Tasks.Parallel.Invoke, and is capturing a local variable that either implements 'System.Security.Cryptography.ICryptoTransform' or has a field of this type. | ThreadUnsafeICryptoTransformLambda.cs:148:17:152:17 | (...) => ... | lambda expression |
3+
| ThreadUnsafeICryptoTransformLambda.cs:143:29:147:17 | (...) => ... | A $@ seems to be used to start a new thread is capturing a local variable that either implements 'System.Security.Cryptography.ICryptoTransform' or has a field of this type. | ThreadUnsafeICryptoTransformLambda.cs:143:29:147:17 | (...) => ... | lambda expression |
4+
| ThreadUnsafeICryptoTransformLambda.cs:148:17:152:17 | (...) => ... | A $@ seems to be used to start a new thread is capturing a local variable that either implements 'System.Security.Cryptography.ICryptoTransform' or has a field of this type. | ThreadUnsafeICryptoTransformLambda.cs:148:17:152:17 | (...) => ... | lambda expression |

0 commit comments

Comments
 (0)