// This would go in dotnet-example/Program.cs
using System;
using System.Net;
using System.IO;
// Copied from https://learn.microsoft.com/en-us/dotnet/api/system.net.webclient?view=net-8.0
public class Test
{
public static void Main(string[] args)
{
if (args == null || args.Length == 0)
{
throw new ApplicationException("Specify the URI of the resource to retrieve.");
}
using WebClient client = new WebClient();
// Add a user agent header in case the
// requested URI contains a query.
client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");
using Stream data = client.OpenRead(args[0]);
using StreamReader reader = new StreamReader(data);
string s = reader.ReadToEnd();
Console.WriteLine(s);
}
}
Run kantra against this rule: kantra analyze --input ./dotnet-example --output ./report --rules ./dotnet-example/rule-example.yaml --log-level 10.
Provider does not find the rule.
NOTE It is worth pointing out that we can find the "NonPortableMethod" in the HelloWorld example. Maybe this is a problem with how assemblies paths are shown in .net8?
@dymurray When I was working through what @shawn-hurley was experiencing I had kind of chalked it up to not being a method call, maybe it was just hard to make the query correct or we should change the query.
Construct a very simple .NET Project.
Start by creating a
dotnet-example
directory. Then create a project file...so it will buildThen write the program.
Write a very basic rule
Run kantra against this rule:
kantra analyze --input ./dotnet-example --output ./report --rules ./dotnet-example/rule-example.yaml --log-level 10
.Provider does not find the rule.
NOTE It is worth pointing out that we can find the "NonPortableMethod" in the HelloWorld example. Maybe this is a problem with how assemblies paths are shown in .net8?