Skip to content

Commit 790db3a

Browse files
committed
C#: Address review comments.
1 parent 63653cd commit 790db3a

File tree

3 files changed

+14
-31
lines changed

3 files changed

+14
-31
lines changed

csharp/ql/src/semmle/code/csharp/dataflow/flowsources/Local.qll

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ abstract class LocalUserInputSource extends LocalFlowSource { }
1616

1717
/** The text of a `TextBox`. */
1818
class TextFieldSource extends LocalUserInputSource {
19-
TextFieldSource() {
20-
this.asExpr() = any(TextControl control).getARead()
21-
}
19+
TextFieldSource() { this.asExpr() = any(TextControl control).getARead() }
2220

2321
override string getSourceType() { result = "TextBox text" }
2422
}

csharp/ql/src/semmle/code/csharp/frameworks/system/windows/Forms.qll

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,15 @@ class SystemWindowsFormsHtmlElement extends SystemWindowsFormsClass {
2626

2727
/** The `System.Windows.Forms.TextBoxBase` class. */
2828
class SystemWindowsFormsTextBoxBase extends SystemWindowsFormsClass {
29-
SystemWindowsFormsTextBoxBase() {
30-
this.hasName("TextBoxBase")
31-
}
29+
SystemWindowsFormsTextBoxBase() { this.hasName("TextBoxBase") }
3230

3331
/** Gets the `Text` property. */
3432
Property getTextProperty() { result = this.getProperty("Text") }
3533
}
3634

3735
/** The `System.Windows.Forms.RichTextBox` class. */
3836
class SystemWindowsFormsRichTextBox extends SystemWindowsFormsClass {
39-
SystemWindowsFormsRichTextBox() {
40-
this.hasName("RichTextBox")
41-
}
37+
SystemWindowsFormsRichTextBox() { this.hasName("RichTextBox") }
4238

4339
/** Gets the `Rtf` property. */
4440
Property getRtfProperty() { result = this.getProperty("Rtf") }
@@ -52,19 +48,15 @@ class SystemWindowsFormsRichTextBox extends SystemWindowsFormsClass {
5248

5349
/** The `System.Windows.Forms.HtmlDocument` class. */
5450
class SystemWindowsFormsHtmlDocumentClass extends SystemWindowsFormsClass {
55-
SystemWindowsFormsHtmlDocumentClass() {
56-
this.hasName("HtmlDocument")
57-
}
51+
SystemWindowsFormsHtmlDocumentClass() { this.hasName("HtmlDocument") }
5852

5953
/** Gets the `Write` method. */
60-
Method getWriteMethod() { result = this.getAMethod() and result.hasName("Write") }
54+
Method getWriteMethod() { result = this.getAMethod("Write") }
6155
}
6256

6357
/** The `System.Windows.Forms.WebBrowser` class. */
6458
class SystemWindowsFormsWebBrowserClass extends SystemWindowsFormsClass {
65-
SystemWindowsFormsWebBrowserClass() {
66-
this.hasName("WebBrowser")
67-
}
59+
SystemWindowsFormsWebBrowserClass() { this.hasName("WebBrowser") }
6860

6961
/** Gets the `DocumentText` property. */
7062
Property getDocumentTextProperty() { result = this.getProperty("DocumentText") }
@@ -78,23 +70,19 @@ private class TextProperty extends Property {
7870
this = c.getSelectedRtfProperty()
7971
)
8072
or
81-
exists(SystemWindowsFormsTextBoxBase tb |
82-
this = tb.getTextProperty().getAnOverrider*()
83-
)
73+
exists(SystemWindowsFormsTextBoxBase tb | this = tb.getTextProperty().getAnOverrider*())
8474
}
8575
}
8676

87-
/** A field that contains a text control. */
88-
class TextControl extends Field
89-
{
77+
/** A variable that contains a text control. */
78+
class TextControl extends Variable {
9079
TextControl() {
9180
this.getType().(ValueOrRefType).getBaseClass*() instanceof SystemWindowsFormsTextBoxBase
9281
}
9382

9483
/** Gets a read of the text property. */
9584
PropertyRead getARead() {
96-
result.getTarget() instanceof TextProperty
97-
and
85+
result.getTarget() instanceof TextProperty and
9886
result.getQualifier() = this.getAnAccess()
9987
}
10088
}

csharp/ql/src/semmle/code/csharp/security/SensitiveActions.qll

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -137,20 +137,17 @@ class SensitiveVariableAccess extends SensitiveExpr, VariableAccess {
137137

138138
/** Reading the `Text` property of a password text box. */
139139
class PasswordTextboxText extends SensitiveExpr, PropertyRead {
140-
PasswordTextboxText() {
141-
this = any(PasswordField p).getARead()
142-
}
140+
PasswordTextboxText() { this = any(PasswordField p).getARead() }
143141
}
144142

145143
/** A field containing a text box used as a password. */
146-
class PasswordField extends TextControl
147-
{
144+
class PasswordField extends TextControl {
148145
PasswordField() {
149146
isSuspicious(this.getName())
150147
or
151148
exists(PropertyWrite write | write.getQualifier() = this.getAnAccess() |
152-
write.getTarget().getName() = "UseSystemPasswordChar" or
153-
write.getTarget().getName() = "PasswordChar"
149+
write.getTarget().getName() = "UseSystemPasswordChar" or
150+
write.getTarget().getName() = "PasswordChar"
154151
)
155152
}
156153
}

0 commit comments

Comments
 (0)