Skip to content

Commit 67e64f2

Browse files
committed
C#: Fix whitespaces
1 parent b38effd commit 67e64f2

File tree

23 files changed

+78
-80
lines changed

23 files changed

+78
-80
lines changed

csharp/fix-whitespaces.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ cat > "$BASEDIR/reformat.vim" <<"EOF"
88
:wq
99
EOF
1010

11-
find "$BASEDIR" \( -name "*.ql" -or -name "*.qll" -or -name "*.csv" \) -exec vim -u /dev/null -s reformat.vim {} \;
11+
find "$BASEDIR" \( -name "*.ql" -or -name "*.qll" -or -name "*.csv" -or -name "*.config" \) -exec vim -u /dev/null -s reformat.vim {} \;
1212

1313
cat > reformat.vim <<"EOF"
1414
:set ff=unix ts=4 et

csharp/ql/src/Configuration/EmptyPasswordInConfigurationFile.config

+21-22
Original file line numberDiff line numberDiff line change
@@ -6,36 +6,35 @@
66

77
<appSettings>
88
<add key="service-dir" value="/opt/deki/bin" />
9-
<add key="root-uri" value="http://localhost/@api" />
9+
<add key="root-uri" value="http://localhost/@api" />
1010
<add key="apikey" value="12345" />
1111
<add key="script" value="/opt/deki/bin/mindtouch.deki.startup.xml" />
1212
</appSettings>
13-
13+
1414
<connectionStrings>
15-
<add name="connectionstring" providerName="System.Data.SqlClient"
16-
connectionString="Server=(local);Database=admtest;Trusted_Connection=False;uid=sa;pwd= ;" /> <!-- VIOLATION -->
17-
<add name="connectionstring2" providerName="System.Data.SqlClient"
18-
connectionString="Server=(local);Database=admtest;Trusted_Connection=False;uid=sa;password = whatever;" /> <!-- NON-VIOLATION -->
19-
</connectionStrings>
15+
<add name="connectionstring" providerName="System.Data.SqlClient"
16+
connectionString="Server=(local);Database=admtest;Trusted_Connection=False;uid=sa;pwd= ;" /> <!-- VIOLATION -->
17+
<add name="connectionstring2" providerName="System.Data.SqlClient"
18+
connectionString="Server=(local);Database=admtest;Trusted_Connection=False;uid=sa;password = whatever;" /> <!-- NON-VIOLATION -->
19+
</connectionStrings>
2020

2121
<system.web>
2222
<httpHandlers>
23-
<add verb="*" path="*"
24-
type="MindTouch.Dream.Http.HttpHandler, mindtouch.core"/>
23+
<add verb="*" path="*"
24+
type="MindTouch.Dream.Http.HttpHandler, mindtouch.core"/>
2525
</httpHandlers>
26-
<!--<customErrors mode="Off"/>-->
27-
<authentication mode="Windows|Forms|Passport|None">
28-
<forms name="name"
29-
loginUrl="url"
30-
protection="All|None|Encryption|Validation"
31-
timeout="30" path="/" >
32-
<credentials passwordFormat="Clear|SHA1|MD5">
33-
<user name="username" password="" /> <!-- VIOLATION -->
34-
</credentials>
35-
</forms>
36-
<passport redirectUrl="internal"/>
37-
</authentication>
38-
26+
<!--<customErrors mode="Off"/>-->
27+
<authentication mode="Windows|Forms|Passport|None">
28+
<forms name="name"
29+
loginUrl="url"
30+
protection="All|None|Encryption|Validation"
31+
timeout="30" path="/" >
32+
<credentials passwordFormat="Clear|SHA1|MD5">
33+
<user name="username" password="" /> <!-- VIOLATION -->
34+
</credentials>
35+
</forms>
36+
<passport redirectUrl="internal"/>
37+
</authentication>
3938
</system.web>
4039

4140
<system.net>

csharp/ql/src/Configuration/PasswordInConfigurationFile.config

+21-22
Original file line numberDiff line numberDiff line change
@@ -6,36 +6,35 @@
66

77
<appSettings>
88
<add key="service-dir" value="/opt/deki/bin" />
9-
<add key="root-uri" value="http://localhost/@api" />
9+
<add key="root-uri" value="http://localhost/@api" />
1010
<add key="apikey" value="12345" />
1111
<add key="script" value="/opt/deki/bin/mindtouch.deki.startup.xml" />
1212
</appSettings>
13-
13+
1414
<connectionStrings>
15-
<add name="connectionstring" providerName="System.Data.SqlClient"
16-
connectionString="Server=(local);Database=admtest;Trusted_Connection=False;uid=sa;pwd=whatever;" /> <!-- VIOLATION -->
17-
<add name="connectionstring2" providerName="System.Data.SqlClient"
18-
connectionString="Server=(local);Database=admtest;Trusted_Connection=False;uid=sa;password = whatever;" /> <!-- VIOLATION -->
19-
</connectionStrings>
15+
<add name="connectionstring" providerName="System.Data.SqlClient"
16+
connectionString="Server=(local);Database=admtest;Trusted_Connection=False;uid=sa;pwd=whatever;" /> <!-- VIOLATION -->
17+
<add name="connectionstring2" providerName="System.Data.SqlClient"
18+
connectionString="Server=(local);Database=admtest;Trusted_Connection=False;uid=sa;password = whatever;" /> <!-- VIOLATION -->
19+
</connectionStrings>
2020

2121
<system.web>
2222
<httpHandlers>
23-
<add verb="*" path="*"
24-
type="MindTouch.Dream.Http.HttpHandler, mindtouch.core"/>
23+
<add verb="*" path="*"
24+
type="MindTouch.Dream.Http.HttpHandler, mindtouch.core"/>
2525
</httpHandlers>
26-
<!--<customErrors mode="Off"/>-->
27-
<authentication mode="Windows|Forms|Passport|None">
28-
<forms name="name"
29-
loginUrl="url"
30-
protection="All|None|Encryption|Validation"
31-
timeout="30" path="/" >
32-
<credentials passwordFormat="Clear|SHA1|MD5">
33-
<user name="username" password="password" /> <!-- VIOLATION -->
34-
</credentials>
35-
</forms>
36-
<passport redirectUrl="internal"/>
37-
</authentication>
38-
26+
<!--<customErrors mode="Off"/>-->
27+
<authentication mode="Windows|Forms|Passport|None">
28+
<forms name="name"
29+
loginUrl="url"
30+
protection="All|None|Encryption|Validation"
31+
timeout="30" path="/" >
32+
<credentials passwordFormat="Clear|SHA1|MD5">
33+
<user name="username" password="password" /> <!-- VIOLATION -->
34+
</credentials>
35+
</forms>
36+
<passport redirectUrl="internal"/>
37+
</authentication>
3938
</system.web>
4039

4140
<system.net>

csharp/ql/src/Security Features/CWE-248/BadWeb.config

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
...
66
</customErrors>
77
</system.web>
8-
</configuration>
8+
</configuration>

csharp/ql/src/Security Features/CWE-248/GoodWeb.config

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
...
66
</customErrors>
77
</system.web>
8-
</configuration>
8+
</configuration>

csharp/ql/src/Security Features/CWE-451/Web.config

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99
</customHeaders>
1010
</httpProtocol>
1111
</system.webServer>
12-
</configuration>
12+
</configuration>

csharp/ql/src/Security Features/CWE-614/Web.config

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<system.web>
44
<authentication>
55
<forms
6-
requireSSL="true"
6+
requireSSL="true"
77
... />
88
</authentication>
99
<httpCookies

csharp/ql/src/semmle/code/csharp/security/dataflow/UrlRedirect.qll

+3-3
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ module UrlRedirect {
174174
)
175175
}
176176
}
177-
177+
178178
/**
179179
* Anything that is setting "location" header in the response headers.
180180
*/
@@ -201,12 +201,12 @@ module UrlRedirect {
201201
this.getExpr() = add.getArgument(1))
202202
or // HttpResponse.Headers["location"] = <user-provided value>
203203
exists(RefType cl, MicrosoftAspNetCoreHttpHttpResponse resp, IndexerAccess ci, Call cs, PropertyAccess qualifier |
204-
qualifier.getTarget() = resp.getHeadersProperty() and
204+
qualifier.getTarget() = resp.getHeadersProperty() and
205205
ci.getTarget() = cl.getAnIndexer() and
206206
qualifier = ci.getQualifier() and
207207
cs.getTarget() = cl.getAnIndexer().getSetter() and
208208
cs.getArgument(0).getValue().toLowerCase() = "location" and
209-
this.asExpr() = cs.getArgument(1))
209+
this.asExpr() = cs.getArgument(1))
210210
}
211211
}
212212
}

csharp/ql/src/semmle/code/csharp/security/dataflow/XSS.qll

+14-14
Original file line numberDiff line numberDiff line change
@@ -526,8 +526,8 @@ module XSS {
526526
this.getExpr() = any(WebPageClass h).getWriteLiteralMethod().getACall().getAnArgument()
527527
}
528528

529-
override string explanation() {
530-
result = "System.Web.WebPages.WebPage.WriteLiteral() method"
529+
override string explanation() {
530+
result = "System.Web.WebPages.WebPage.WriteLiteral() method"
531531
}
532532
}
533533

@@ -539,9 +539,9 @@ module XSS {
539539
WebPageWriteLiteralToSink() {
540540
this.getExpr() = any(WebPageClass h).getWriteLiteralToMethod().getACall().getAnArgument()
541541
}
542-
543-
override string explanation() {
544-
result = "System.Web.WebPages.WebPage.WriteLiteralTo() method"
542+
543+
override string explanation() {
544+
result = "System.Web.WebPages.WebPage.WriteLiteralTo() method"
545545
}
546546
}
547547

@@ -555,9 +555,9 @@ module XSS {
555555
MicrosoftAspNetCoreMvcHtmlHelperRawSink() {
556556
this.getExpr() = any(MicrosoftAspNetCoreMvcHtmlHelperClass h).getRawMethod().getACall().getAnArgument()
557557
}
558-
559-
override string explanation() {
560-
result = "Microsoft.AspNetCore.Mvc.ViewFeatures.HtmlHelper.Raw() method"
558+
559+
override string explanation() {
560+
result = "Microsoft.AspNetCore.Mvc.ViewFeatures.HtmlHelper.Raw() method"
561561
}
562562
}
563563

@@ -569,19 +569,19 @@ module XSS {
569569
MicrosoftAspNetRazorPageWriteLiteralSink() {
570570
this.getExpr() = any(MicrosoftAspNetCoreMvcRazorPageBase h).getWriteLiteralMethod().getACall().getAnArgument()
571571
}
572-
573-
override string explanation() {
574-
result = "Microsoft.AspNetCore.Mvc.Razor.RazorPageBase.WriteLiteral() method"
572+
573+
override string explanation() {
574+
result = "Microsoft.AspNetCore.Mvc.Razor.RazorPageBase.WriteLiteral() method"
575575
}
576576
}
577-
577+
578578
/**
579579
* HtmlString that may be rendered as is need to have sanitized value
580580
*/
581581
class MicrosoftAspNetHtmlStringSink extends AspNetCoreSink {
582582
MicrosoftAspNetHtmlStringSink() {
583-
exists (ObjectCreation c, MicrosoftAspNetCoreHttpHtmlString s |
584-
c.getTarget() = s.getAConstructor() and
583+
exists (ObjectCreation c, MicrosoftAspNetCoreHttpHtmlString s |
584+
c.getTarget() = s.getAConstructor() and
585585
this.asExpr() = c.getAnArgument())
586586
}
587587
}

csharp/ql/test/query-tests/Security Features/CWE-011/Web.config

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
defaultLanguage="c#"
66
/>
77
</system.web>
8-
</configuration>
8+
</configuration>

csharp/ql/test/query-tests/Security Features/CWE-011/bad/Web.config

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
debug="true"
77
/>
88
</system.web>
9-
</configuration>
9+
</configuration>

csharp/ql/test/query-tests/Security Features/CWE-079/XSS/XSSAspNet.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,4 @@ public override void Execute()
4848
}
4949
}
5050

51-
// source-extractor-options: /r:${testdir}/../../../../../packages/Microsoft.AspNet.WebPages.3.2.3/lib/net45/System.Web.WebPages.dll /r:${testdir}/../../../../../packages/Microsoft.AspNet.Mvc.5.2.3/lib/net45/System.Web.Mvc.dll /r:System.Dynamic.Runtime.dll /r:System.Runtime.Extensions.dll /r:System.Linq.Expressions.dll /r:System.Web.dll /r:C:\Windows\Microsoft.NET\Framework64\v4.0.30319\System.Web.dll /r:System.Collections.Specialized.dll
51+
// source-extractor-options: /r:${testdir}/../../../../../packages/Microsoft.AspNet.WebPages.3.2.3/lib/net45/System.Web.WebPages.dll /r:${testdir}/../../../../../packages/Microsoft.AspNet.Mvc.5.2.3/lib/net45/System.Web.Mvc.dll /r:System.Dynamic.Runtime.dll /r:System.Runtime.Extensions.dll /r:System.Linq.Expressions.dll /r:System.Web.dll /r:C:\Windows\Microsoft.NET\Framework64\v4.0.30319\System.Web.dll /r:System.Collections.Specialized.dll

csharp/ql/test/query-tests/Security Features/CWE-079/XSS/XSSAspNetCore.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,4 @@ public IActionResult Contact()
7676
}
7777
}
7878

79-
// initial-extractor-options: /r:netstandard.dll /r:${testdir}/../../../../../packages/Microsoft.AspNetCore.Mvc.1.1.3/lib/net451/Microsoft.AspNetCore.Mvc.dll /r:${testdir}/../../../../../packages/Microsoft.AspNetCore.Mvc.Core.1.1.3/lib/net451/Microsoft.AspNetCore.Mvc.Core.dll /r:${testdir}/../../../../../packages/Microsoft.AspNetCore.Antiforgery.1.1.2/lib/net451/Microsoft.AspNetCore.Antiforgery.dll /r:${testdir}/../../../../../packages/Microsoft.AspNetCore.Mvc.ViewFeatures.1.1.3/lib/net451/Microsoft.AspNetCore.Mvc.ViewFeatures.dll /r:${testdir}/../../../../../packages/Microsoft.AspNetCore.Mvc.Abstractions.1.1.3/lib/net451/Microsoft.AspNetCore.Mvc.Abstractions.dll /r:${testdir}/../../../../../packages\Microsoft.AspNetCore.Http.Abstractions.1.1.2\lib\net451\Microsoft.AspNetCore.Http.Abstractions.dll /r:${testdir}/../../../../../packages/Microsoft.AspNetCore.Html.Abstractions.1.1.2/lib/netstandard1.0/Microsoft.AspNetCore.Html.Abstractions.dll /r:${testdir}/../../../../../packages/Microsoft.AspNetCore.Http.Features.1.1.2\lib\net451\Microsoft.AspNetCore.Http.Features.dll /r:${testdir}/../../../../../packages\Microsoft.Extensions.Primitives.2.1.0\lib\netstandard2.0\Microsoft.Extensions.Primitives.dll /r:System.Linq.dll /r:System.Linq.Expressions.dll /r:System.Linq.Queryable.dll
79+
// initial-extractor-options: /r:netstandard.dll /r:${testdir}/../../../../../packages/Microsoft.AspNetCore.Mvc.1.1.3/lib/net451/Microsoft.AspNetCore.Mvc.dll /r:${testdir}/../../../../../packages/Microsoft.AspNetCore.Mvc.Core.1.1.3/lib/net451/Microsoft.AspNetCore.Mvc.Core.dll /r:${testdir}/../../../../../packages/Microsoft.AspNetCore.Antiforgery.1.1.2/lib/net451/Microsoft.AspNetCore.Antiforgery.dll /r:${testdir}/../../../../../packages/Microsoft.AspNetCore.Mvc.ViewFeatures.1.1.3/lib/net451/Microsoft.AspNetCore.Mvc.ViewFeatures.dll /r:${testdir}/../../../../../packages/Microsoft.AspNetCore.Mvc.Abstractions.1.1.3/lib/net451/Microsoft.AspNetCore.Mvc.Abstractions.dll /r:${testdir}/../../../../../packages\Microsoft.AspNetCore.Http.Abstractions.1.1.2\lib\net451\Microsoft.AspNetCore.Http.Abstractions.dll /r:${testdir}/../../../../../packages/Microsoft.AspNetCore.Html.Abstractions.1.1.2/lib/netstandard1.0/Microsoft.AspNetCore.Html.Abstractions.dll /r:${testdir}/../../../../../packages/Microsoft.AspNetCore.Http.Features.1.1.2\lib\net451\Microsoft.AspNetCore.Http.Features.dll /r:${testdir}/../../../../../packages\Microsoft.Extensions.Primitives.2.1.0\lib\netstandard2.0\Microsoft.Extensions.Primitives.dll /r:System.Linq.dll /r:System.Linq.Expressions.dll /r:System.Linq.Queryable.dll

csharp/ql/test/query-tests/Security Features/CWE-248/MissingASPNETGlobalErrorHandler/WebConfigOff/Web.config

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
<customErrors mode="Off">
55
</customErrors>
66
</system.web>
7-
</configuration>
7+
</configuration>

csharp/ql/test/query-tests/Security Features/CWE-248/MissingASPNETGlobalErrorHandler/WebConfigOffButGlobal/Web.config

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
<customErrors mode="Off">
55
</customErrors>
66
</system.web>
7-
</configuration>
7+
</configuration>

csharp/ql/test/query-tests/Security Features/CWE-451/MissingXFrameOptions/CodeAddedHeader/Web.config

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
<configuration>
33
<system.web>
44
</system.web>
5-
</configuration>
5+
</configuration>

csharp/ql/test/query-tests/Security Features/CWE-451/MissingXFrameOptions/NoHeader/Web.config

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
<configuration>
33
<system.web>
44
</system.web>
5-
</configuration>
5+
</configuration>

csharp/ql/test/query-tests/Security Features/CWE-451/MissingXFrameOptions/WebConfigAddedHeader/Web.config

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99
</customHeaders>
1010
</httpProtocol>
1111
</system.webServer>
12-
</configuration>
12+
</configuration>

csharp/ql/test/query-tests/Security Features/CWE-548/web.config

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
<system.webServer>
44
<directoryBrowse enabled="true" />
55
</system.webServer>
6-
</configuration>
6+
</configuration>

csharp/ql/test/query-tests/Security Features/CWE-614/RequireSSL/AddedInCode/Web.config

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
<system.web>
44
<httpCookies />
55
</system.web>
6-
</configuration>
6+
</configuration>

csharp/ql/test/query-tests/Security Features/CWE-614/RequireSSL/AddedInForms/Web.config

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
</authentication>
77
<httpCookies />
88
</system.web>
9-
</configuration>
9+
</configuration>

csharp/ql/test/query-tests/Security Features/CWE-614/RequireSSL/HttpCookiesCorrect/Web.config

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
</authentication>
77
<httpCookies requireSSL="true"/>
88
</system.web>
9-
</configuration>
9+
</configuration>

csharp/ql/test/query-tests/Security Features/CWE-614/RequireSSL/RequireSSLMissing/Web.config

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
</authentication>
77
<httpCookies />
88
</system.web>
9-
</configuration>
9+
</configuration>

0 commit comments

Comments
 (0)