-
Notifications
You must be signed in to change notification settings - Fork 231
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
0f74c56
commit 8dab911
Showing
7 changed files
with
74 additions
and
15 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
.../Automapper/AutoMapper--net461-S2445.json → .../Automapper/AutoMapper--net461-S6507.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...per/AutoMapper--netstandard2.0-S2445.json → ...per/AutoMapper--netstandard2.0-S6507.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<p>Locking on a local variable can undermine synchronization because two different threads running the same method in parallel will potentially lock | ||
on different instances of the same object, allowing them to access the synchronized block at the same time.</p> | ||
<h2>Noncompliant Code Example</h2> | ||
<pre> | ||
private void DoSomething() | ||
{ | ||
object local = new object(); | ||
// Code potentially modifying the local variable ... | ||
|
||
lock (local) // Noncompliant | ||
{ | ||
// ... | ||
} | ||
} | ||
</pre> | ||
<h2>Compliant Solution</h2> | ||
<pre> | ||
private readonly object lockObj = new object(); | ||
|
||
private void DoSomething() | ||
{ | ||
lock (lockObj) | ||
{ | ||
//... | ||
} | ||
} | ||
</pre> | ||
<h2>See</h2> | ||
<ul> | ||
<li> <a href="https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/statements/lock">Lock Statement</a> - lock statement - ensure | ||
exclusive access to a shared resource </li> | ||
<li> <a href="https://cwe.mitre.org/data/definitions/412">MITRE, CWE-412</a> - Unrestricted Externally Accessible Lock </li> | ||
<li> <a href="https://cwe.mitre.org/data/definitions/413">MITRE, CWE-413</a> - Improper Resource Locking </li> | ||
</ul> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"title": "Blocks should not be synchronized on local variables", | ||
"type": "BUG", | ||
"status": "ready", | ||
"remediation": { | ||
"func": "Constant\/Issue", | ||
"constantCost": "15min" | ||
}, | ||
"tags": [ | ||
"cwe", | ||
"multi-threading" | ||
], | ||
"defaultSeverity": "Major", | ||
"ruleSpecification": "RSPEC-6507", | ||
"sqKey": "S6507", | ||
"scope": "All", | ||
"securityStandards": { | ||
"CWE": [ | ||
412, | ||
413 | ||
] | ||
}, | ||
"quickfix": "unknown" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters