Skip to content

Commit 8acb7aa

Browse files
mary-georgiou-sonarsourcesonartech
authored and
sonartech
committed
NET-763 Update RSPEC before 10.4 release
1 parent d00f951 commit 8acb7aa

File tree

15 files changed

+52
-15
lines changed

15 files changed

+52
-15
lines changed

analyzers/rspec/cs/S1451.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
"func": "Constant\/Issue",
1313
"constantCost": "5min"
1414
},
15-
"tags": [],
15+
"tags": [
16+
"convention"
17+
],
1618
"defaultSeverity": "Blocker",
1719
"ruleSpecification": "RSPEC-1451",
1820
"sqKey": "S1451",

analyzers/rspec/cs/S1751.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212
"func": "Constant\/Issue",
1313
"constantCost": "5min"
1414
},
15-
"tags": [],
15+
"tags": [
16+
"confusing",
17+
"bad-practice"
18+
],
1619
"defaultSeverity": "Major",
1720
"ruleSpecification": "RSPEC-1751",
1821
"sqKey": "S1751",

analyzers/rspec/cs/S1764.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
"func": "Constant\/Issue",
1313
"constantCost": "2min"
1414
},
15-
"tags": [],
15+
"tags": [
16+
"suspicious"
17+
],
1618
"defaultSeverity": "Major",
1719
"ruleSpecification": "RSPEC-1764",
1820
"sqKey": "S1764",

analyzers/rspec/cs/S2201.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212
"func": "Constant\/Issue",
1313
"constantCost": "10min"
1414
},
15-
"tags": [],
15+
"tags": [
16+
"suspicious",
17+
"confusing"
18+
],
1619
"defaultSeverity": "Major",
1720
"ruleSpecification": "RSPEC-2201",
1821
"sqKey": "S2201",

analyzers/rspec/cs/S2325.html

+3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ <h3>Exceptions</h3>
2525
<li> <a href="https://learn.microsoft.com/en-us/dotnet/api/system.web.sessionstate.sessionstatemodule.end">Session_End</a> </li>
2626
<li> <a href="https://learn.microsoft.com/en-us/dotnet/api/system.web.sessionstate.sessionstatemodule.start">Session_Start</a> </li>
2727
</ul>
28+
<p>Event handler methods part of a <a href="https://learn.microsoft.com/en-us/dotnet/desktop/winforms">Windows Forms</a> or <a
29+
href="https://learn.microsoft.com/en-us/dotnet/desktop/wpf">Windows Presentation Foundation</a> class are excluded because they can’t be made
30+
<code>static</code>.</p>
2831
<h2>How to fix it</h2>
2932
<h3>Code examples</h3>
3033
<h4>Noncompliant code example</h4>

analyzers/rspec/cs/S3168.html

+5-2
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,16 @@ <h2>Why is this an issue?</h2>
1414
</ul>
1515
<h3>Exceptions</h3>
1616
<ul>
17-
<li> Methods with the <a href="https://learn.microsoft.com/en-us/dotnet/api/system.eventhandler"><code>EventHandler</code></a> delegate signature. Using <code>void</code> for <code>EventHandler</code> is compliant with the TAP model. <pre>
17+
<li> Methods implementing an interface </li>
18+
<li> Methods overriding a base class method </li>
19+
<li> Virtual methods </li>
20+
<li> Methods with the <a href="https://learn.microsoft.com/en-us/dotnet/api/system.eventhandler"><code>EventHandler</code></a> delegate signature Using <code>void</code> for <code>EventHandler</code> is compliant with the TAP model. <pre>
1821
public async void button1_Click(object sender, EventArgs e)
1922
{
2023
await DoSomethingAsync();
2124
}
2225
</pre> </li>
23-
<li> Methods name matching <code>On[A-Z]\w*</code> pattern. Some frameworks may not use the same <code>EventHandler</code> method signature <pre>
26+
<li> Methods name matching <code>On[A-Z]\w*</code> pattern Some frameworks may not use the same <code>EventHandler</code> method signature. <pre>
2427
public async void OnClick(EventContext data)
2528
{
2629
await DoSomethingAsync();

analyzers/rspec/cs/S3981.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
"func": "Constant\/Issue",
1313
"constantCost": "2min"
1414
},
15-
"tags": [],
15+
"tags": [
16+
"confusing"
17+
],
1618
"defaultSeverity": "Major",
1719
"ruleSpecification": "RSPEC-3981",
1820
"sqKey": "S3981",

analyzers/rspec/cs/S6932.html

+11-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ <h4>Noncompliant code example</h4>
143143
var name = Request.Form["name"]; // Noncompliant: Request.Form
144144
var birthdate = DateTime.Parse(Request.Form["Birthdate"]); // Noncompliant: Request.Form
145145

146-
var origin = Request.Headers[HeaderNames.Origin]; // Noncompliant: Request.Headers
147146
var locale = Request.Query.TryGetValue("locale", out var locales)
148147
? locales.ToString()
149148
: "en-US"; // Noncompliant: Request.Query
@@ -264,6 +263,17 @@ <h4>Compliant solution</h4>
264263
// ...
265264
}
266265
}
266+
267+
public IActionResult Post()
268+
{
269+
var origin = Request.Headers[HeaderNames.Origin]; // Compliant: Access via non-constant field
270+
var nameField = "name";
271+
var name = Request.Form[nameField]; // Compliant: Access via local
272+
var birthdate = DateTime.Parse(Request.Form["Birthdate"]); // Compliant: Access via constant and variable keys is mixed.
273+
// Model binding would only work partially in the method, so we do not raise here.
274+
return Ok();
275+
// ..
276+
}
267277
</pre>
268278
<h3>How does this work?</h3>
269279
<p>Model binding in ASP.NET Core MVC and ASP.NET MVC 4.x works by automatically mapping data from HTTP requests to action method parameters. Here’s a

analyzers/rspec/vbnet/S1451.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
"func": "Constant\/Issue",
1313
"constantCost": "5min"
1414
},
15-
"tags": [],
15+
"tags": [
16+
"convention"
17+
],
1618
"defaultSeverity": "Blocker",
1719
"ruleSpecification": "RSPEC-1451",
1820
"sqKey": "S1451",

analyzers/rspec/vbnet/S1751.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212
"func": "Constant\/Issue",
1313
"constantCost": "5min"
1414
},
15-
"tags": [],
15+
"tags": [
16+
"confusing",
17+
"bad-practice"
18+
],
1619
"defaultSeverity": "Major",
1720
"ruleSpecification": "RSPEC-1751",
1821
"sqKey": "S1751",

analyzers/rspec/vbnet/S1764.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
"func": "Constant\/Issue",
1313
"constantCost": "2min"
1414
},
15-
"tags": [],
15+
"tags": [
16+
"suspicious"
17+
],
1618
"defaultSeverity": "Major",
1719
"ruleSpecification": "RSPEC-1764",
1820
"sqKey": "S1764",

analyzers/rspec/vbnet/S2077.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<p>Formatted SQL queries can be difficult to maintain, debug and can increase the risk of SQL injection when concatenating untrusted values into the
2-
query. However, this rule doesn’t detect SQL injections (unlike rule {rule:vbnet:S3649}), the goal is only to highlight complex/formatted queries.</p>
2+
query. However, this rule doesn’t detect SQL injections, the goal is only to highlight complex/formatted queries.</p>
33
<h2>Ask Yourself Whether</h2>
44
<ul>
55
<li> Some parts of the query come from untrusted values (like user inputs). </li>

analyzers/rspec/vbnet/S3981.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
"func": "Constant\/Issue",
1313
"constantCost": "2min"
1414
},
15-
"tags": [],
15+
"tags": [
16+
"confusing"
17+
],
1618
"defaultSeverity": "Major",
1719
"ruleSpecification": "RSPEC-3981",
1820
"sqKey": "S3981",

analyzers/src/SonarAnalyzer.CSharp/sonarpedia.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"languages": [
44
"CSH"
55
],
6-
"latest-update": "2024-11-22T15:47:41.648301100Z",
6+
"latest-update": "2024-12-17T16:28:59.313236800Z",
77
"options": {
88
"no-language-in-filenames": true
99
}

analyzers/src/SonarAnalyzer.VisualBasic/sonarpedia.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"languages": [
44
"VBNET"
55
],
6-
"latest-update": "2024-11-22T15:48:04.322624300Z",
6+
"latest-update": "2024-12-17T16:29:24.459345100Z",
77
"options": {
88
"no-language-in-filenames": true
99
}

0 commit comments

Comments
 (0)