Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -454,5 +454,54 @@ End Namespace
await VerifyCSharpDiagnostic(cSharpTest, null, optionsWithProjectConfig).ConfigureAwait(false);
await VerifyVisualBasicDiagnostic(visualBasicTest, null, optionsWithProjectConfig).ConfigureAwait(false);
}

[TestCategory("Detect")]
[TestMethod]
public async Task DynamicArgument()
{
var cSharpTest = @"
class Test
{
public void Action(string foo)
{
Method(foo);
}

private void Method(dynamic d)
{

}
}
";


var testConfig = @"
TaintEntryPoints:
Test:
ClassName: Test

Behavior:
DynamicMethod:
ClassName: Test
Name: Method
Method:
ArgTypes: ""(dynamic)""
InjectableArguments: [SCS0001: 0]";

var options = ConfigurationTest.CreateAnalyzersOptionsWithConfig(testConfig);

var cSharpExpected =
new[]
{
new DiagnosticResult
{
Id = "SCS0001",
Severity = DiagnosticSeverity.Warning,
}.WithLocation(6, 16)
};

await VerifyCSharpDiagnostic(cSharpTest, cSharpExpected, options).ConfigureAwait(false);
// there's not really an equivalent to dynamic in VB.NET, so no test for it
}
}
}
2 changes: 1 addition & 1 deletion SecurityCodeScan/Config/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ private void ValidateArgTypes(string argTypes, string nameSpace, string classNam
throw new Exception(
$"Leading or trailing white space in argument of {nameSpace}.{className}.{name}");

if (!argType.Contains("."))
if (!argType.Contains(".") && !argType.Equals("dynamic"))
throw new Exception($"Argument type lacks namespace in {nameSpace}.{className}.{name}");

if (argType.Contains("this "))
Expand Down