Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.2 dev branch #192

Merged
merged 41 commits into from
Apr 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
0d4aa47
Major add of unit tests for most commands. Some fixes as a resulting…
Mar 30, 2020
a2c4b24
Minor cleanup of unnecessary test dll's in Commands project and updat…
Mar 30, 2020
600ace4
Refactor+ of code structure for technical debt and better result obje…
Apr 6, 2020
d9627dd
Refactor+ of code structure for technical debt and better result obje…
Apr 6, 2020
a27098c
Rebase commit back into 1.2
Apr 6, 2020
1bbe2c7
Merge of rebase and 1.2DevBranch
Apr 6, 2020
e05bb2c
Code cleanup tool to raise hygiene consistency. Unused files removed.
Apr 6, 2020
a000701
Removed unneccesary file as per PR comments.
Apr 7, 2020
ab8a7ac
Removed unneeded versions of these files which already exists in the …
Apr 7, 2020
e878810
Unneccessary files.
Apr 7, 2020
da53dd8
Update contains to equals comparison for file format checks.
Apr 7, 2020
3b23ab6
Update AppInspector.CLI/Program.cs
guyacosta Apr 7, 2020
28a6dac
Update AppInspector.CLI/Program.cs
guyacosta Apr 7, 2020
2f7578b
Optimiztion to remove unneeded type specific json writers that have s…
Apr 7, 2020
dde04bc
Merge branch '1.2DevBranch' of https://github.com/microsoft/Applicati…
Apr 7, 2020
2bb0c88
Set missing defaults for CLIAnalyzeCmdOptions
Apr 7, 2020
451f109
Fix in path for CLI exe affecting LGTM running unit test
Apr 7, 2020
f0ba645
Cast improvements suggestions from PR
Apr 7, 2020
d9ba137
removing commented out code
Apr 7, 2020
26bf6f8
LGTM suggestions hygiene improvements
Apr 7, 2020
7dad3cb
Update RulesEngine/RuleProcessor.cs
guyacosta Apr 7, 2020
dd20d62
Update RulesEngine/RuleProcessor.cs
guyacosta Apr 7, 2020
cc83d0f
Merge branch '1.2DevBranch' of https://github.com/microsoft/Applicati…
Apr 7, 2020
42c5413
Add Build Tests to Pipeline
daalcant Apr 7, 2020
ff37b34
Update version.json
daalcant Apr 7, 2020
6717e8a
Remove warning exclusions; one fix for lgtm and removed unneeded code…
Apr 7, 2020
f17fb75
Update core-pipeline.yml for Azure Pipelines
daalcant Apr 7, 2020
899f2da
Update core-pipeline.yml for Azure Pipelines
daalcant Apr 7, 2020
508cec6
Setter default values used rather than ctor; code spacing hygiene fix…
Apr 8, 2020
52f16f8
Merge branch '1.2DevBranch' of https://github.com/microsoft/Applicati…
Apr 8, 2020
9583290
CodeMaid final hygiene cleanup
Apr 8, 2020
94fc0e7
Unit test succeeding locally but not in build; attempt to correct.
Apr 8, 2020
e3c61a7
Attempt to address devops build dependency issues not seen locally.
Apr 8, 2020
4756e53
dep update
Apr 8, 2020
cbed817
Minor attempts at resolving ado build issue for UnitTest
Apr 8, 2020
7041787
Create output.txt
guyacosta Apr 8, 2020
109fcc9
Test framework update
Apr 8, 2020
304df46
Fix #191 made to master added here also.
Apr 8, 2020
6932ead
Merge branch 'master' into 1.2DevBranch
guyacosta Apr 8, 2020
68b8607
Fix test execution bugs in pipeline
daalcant Apr 9, 2020
1e80738
Revert some dep changes
daalcant Apr 9, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 2 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -261,12 +261,6 @@ __pycache__/
*.pyc

# App Inspector artifacts
/AppInspector/htmlReport
/AppInspectorLog.txt
/AppInspector/Log.txt
/AppInspector/LogB4.txt
/AppInspector/wip.txt
/AppInspector/linux/ApplicationInspector
/Microsoft.DevSkim/linux/ApplicationInspector
/AppInspector/Resources/defaultRules.json
/AppInspector/Resources/defaultRulesPkd.json
/UnitTest.Commands/output
/RulesPacker/log.txt
10 changes: 7 additions & 3 deletions AppInspector.CLI/AppInspector.CLI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

<ItemGroup>
<ProjectReference Include="..\AppInspector\AppInspector.Commands.csproj" />
<ProjectReference Include="..\RulesEngine\AppInspector.RulesEngine.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down Expand Up @@ -147,9 +148,6 @@
<None Update="html\resources\webfonts\fa-solid-900.woff2">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="preferences\tagcounters.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="preferences\tagreportgroups.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand All @@ -159,4 +157,10 @@
<None Include="..\LICENSE.txt" Pack="true" PackagePath="" />
<None Include="..\icon-128.png" Pack="true" PackagePath="" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="DotLiquid" Version="2.0.325" />
<PackageReference Include="NLog" Version="4.7.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,37 @@
// Licensed under the MIT License. See LICENSE.txt in the project root for license information.

using CommandLine;
using NLog;
using Microsoft.ApplicationInspector.Commands;

namespace Microsoft.ApplicationInspector.Commands
namespace Microsoft.ApplicationInspector.CLI
{
public class AllCommandOptions
/// <summary>
/// CLI command option classes add output arguments to common properties for each command verb
/// </summary>
///
public class CLICommandOptions : CommandOptions
{
public Logger Log { get; set; }

[Option('l', "log-file-path", Required = false, HelpText = "Log file path")]
public string LogFilePath { get; set; }
[Option('v', "log-file-level", Required = false, HelpText = "Log file level [Debug|Info|Warn|Error|Trace|Fatal|Off]", Default = "Error")]
public string LogFileLevel { get; set; }

public bool CloseLogOnCommandExit { get; set; }
[Option('o', "output-file-path", Required = false, HelpText = "Output file path")]
public string OutputFilePath { get; set; }

[Option('f', "output-file-format", Required = false, HelpText = "Output format [json|text]", Default = "text")]
public string OutputFileFormat { get; set; } = "text";
}

/// <summary>
/// Command option classes for each command verb
/// CLI command distinct arguments
/// </summary>

[Verb("analyze", HelpText = "Inspect source directory/file/compressed file (.tgz|zip) against defined characteristics")]
public class AnalyzeCommandOptions : AllCommandOptions
public class CLIAnalyzeCmdOptions : CLICommandOptions
{
[Option('s', "source-path", Required = true, HelpText = "Source file or directory to inspect")]
public string SourcePath { get; set; }

[Option('o', "output-file-path", Required = false, HelpText = "Output file path")]
public string OutputFilePath { get; set; }

[Option('f', "output-file-format", Required = false, HelpText = "Output format [html|json|text]", Default = "html")]
public string OutputFileFormat { get; set; }

[Option('e', "text-format", Required = false, HelpText = "Match text format specifiers", Default = "Tag:%T,Rule:%N,Ruleid:%R,Confidence:%X,File:%F,Sourcetype:%t,Line:%L,Sample:%m")]
public string TextOutputFormat { get; set; }

[Option('r', "custom-rules-path", Required = false, HelpText = "Custom rules file or directory path")]
public string CustomRulesPath { get; set; }

[Option('t', "tag-output-only", Required = false, HelpText = "Output only identified tags", Default = false)]
public bool SimpleTagsOnly { get; set; }
[Option('h', "match-depth", Required = false, HelpText = "First match or best match based on confidence level (first|best)", Default = "best")]
guyacosta marked this conversation as resolved.
Show resolved Hide resolved
public string MatchDepth { get; set; } = "best";

[Option('i', "ignore-default-rules", Required = false, HelpText = "Exclude default rules bundled with application", Default = false)]
public bool IgnoreDefaultRules { get; set; }
Expand All @@ -53,19 +44,23 @@ public class AnalyzeCommandOptions : AllCommandOptions
public bool SuppressBrowserOpen { get; set; }

[Option('c', "confidence-filters", Required = false, HelpText = "Output only matches with specified confidence <value>,<value> [high|medium|low]", Default = "high,medium")]
public string ConfidenceFilters { get; set; }
public string ConfidenceFilters { get; set; } = "high,medium";

[Option('k', "file-path-exclusions", Required = false, HelpText = "Exclude source files (none|default: sample,example,test,docs,.vs,.git)", Default = "sample,example,test,docs,.vs,.git")]
public string FilePathExclusions { get; set; }
public string FilePathExclusions { get; set; } = "sample,example,test,docs,.vs,.git";

[Option('x', "console-verbosity", Required = false, HelpText = "Console verbosity [high|medium|low|none]", Default = "medium")]
public string ConsoleVerbosityLevel { get; set; }
[Option('f', "output-file-format", Required = false, HelpText = "Output format [html|json|text]", Default = "html")]
public new string OutputFileFormat { get; set; } = "html";

}
[Option('e', "text-format", Required = false, HelpText = "Match text format specifiers", Default = "Tag:%T,Rule:%N,Ruleid:%R,Confidence:%X,File:%F,Sourcetype:%t,Line:%L,Sample:%m")]
public string TextOutputFormat { get; set; } = "Tag:%T,Rule:%N,Ruleid:%R,Confidence:%X,File:%F,Sourcetype:%t,Line:%L,Sample:%m";

[Option('t', "tag-output-only", Required = false, HelpText = "Output only identified tags", Default = false)]
public bool SimpleTagsOnly { get; set; }
}

[Verb("tagdiff", HelpText = "Compares unique tag values between two source paths")]
public class TagDiffCommandOptions : AllCommandOptions
public class CLITagDiffCmdOptions : CLICommandOptions
{
[Option("src1", Required = true, HelpText = "Source 1 to compare")]
public string SourcePath1 { get; set; }
Expand All @@ -74,102 +69,70 @@ public class TagDiffCommandOptions : AllCommandOptions
public string SourcePath2 { get; set; }

[Option('t', "test-type", Required = false, HelpText = "Type of test to run [equality|inequality]", Default = "equality")]
public string TestType { get; set; }
public string TestType { get; set; } = "equality";

[Option('k', "file-path-exclusions", Required = false, HelpText = "Exclude source files (none|default: sample,example,test,docs,.vs,.git)", Default = "sample,example,test,docs,.vs,.git")]
public string FilePathExclusions { get; set; }
public string FilePathExclusions { get; set; } = "sample,example,test,docs,.vs,.git";

[Option('r', "custom-rules-path", Required = false, HelpText = "Custom rules file or directory path")]
public string CustomRulesPath { get; set; }

[Option('i', "ignore-default-rules", Required = false, HelpText = "Exclude default rules bundled with application", Default = false)]
public bool IgnoreDefaultRules { get; set; }

[Option('o', "output-file-path", Required = false, HelpText = "Output file path")]
public string OutputFilePath { get; set; }

[Option('x', "console-verbosity", Required = false, HelpText = "Console verbosity [high|medium|low|none]", Default = "medium")]
public string ConsoleVerbosityLevel { get; set; }

}


[Verb("tagtest", HelpText = "Test (T/F) for presence of custom rule set in source")]
public class TagTestCommandOptions : AllCommandOptions
public class CLITagTestCmdOptions : CLICommandOptions
{
[Option('s', "source-path", Required = true, HelpText = "Source file or directory to inspect")]
public string SourcePath { get; set; }

[Option('t', "test-type", Required = false, HelpText = "Test to perform [rulespresent|rulesnotpresent] ", Default = "rulespresent")]
public string TestType { get; set; }
public string TestType { get; set; } = "rulespresent";

[Option('r', "custom-rules-path", Required = false, HelpText = "Custom rules file or directory path")]
public string CustomRulesPath { get; set; }

[Option('k', "file-path-exclusions", Required = false, HelpText = "Exclude source files (none|default: sample,example,test,docs,.vs,.git)", Default = "sample,example,test,docs,.vs,.git")]
public string FilePathExclusions { get; set; }

[Option('o', "output-file-path", Required = false, HelpText = "Output file path")]
public string OutputFilePath { get; set; }

[Option('x', "console-verbosity", Required = false, HelpText = "Console verbosity [high|medium|low|none]", Default = "medium")]
public string ConsoleVerbosityLevel { get; set; }

public string FilePathExclusions { get; set; } = "sample,example,test,docs,.vs,.git";
}

[Verb("exporttags", HelpText = "Export unique rule tags to view what code features may be detected")]
public class ExportTagsCommandOptions : AllCommandOptions
public class CLIExportTagsCmdOptions : CLICommandOptions
{
[Option('r', "custom-rules-path", Required = false, HelpText = "Custom rules file or directory path")]
public string CustomRulesPath { get; set; }

[Option('i', "ignore-default-rules", Required = false, HelpText = "Exclude default rules bundled with application", Default = false)]
public bool IgnoreDefaultRules { get; set; }

[Option('o', "output-file-path", Required = false, HelpText = "Output file path")]
public string OutputFilePath { get; set; }

[Option('x', "console-verbosity", Required = false, HelpText = "Console verbosity [high|medium|low|none]", Default = "medium")]
public string ConsoleVerbosityLevel { get; set; }
}


[Verb("verifyrules", HelpText = "Verify custom rules syntax is valid")]
public class VerifyRulesCommandOptions : AllCommandOptions
public class CLIVerifyRulesCmdOptions : CLICommandOptions
{
[Option('d', "verify-default-rules", Required = false, HelpText = "Verify default rules")]
public bool VerifyDefaultRules { get; set; }

[Option('r', "custom-rules-path", Required = false, HelpText = "Custom rules file or directory path")]
public string CustomRulesPath { get; set; }

[Option('o', "output-file-path", Required = false, HelpText = "Output file path")]
public string OutputFilePath { get; set; }

[Option('x', "console-verbosity", Required = false, HelpText = "Console verbosity [high|medium|low|none]", Default = "medium")]
public string ConsoleVerbosityLevel { get; set; }


[Option('a', "fail-fast", Required = false, HelpText = "Fail fast", Default = false)]
public bool Failfast { get; set; }
}

[Verb("packrules", HelpText = "Combine multiple rule files into one file for ease in distribution")]
public class PackRulesCommandOptions : AllCommandOptions
public class CLIPackRulesCmdOptions : CLICommandOptions
{
[Option('d', "pack-default-rules", Required = false, HelpText = "Repack default rules. Automatic on Application Inspector build")]
public bool RepackDefaultRules { get; set; }

[Option('r', "custom-rules-path", Required = false, HelpText = "Custom rules file or directory path")]
public string CustomRulesPath { get; set; }

[Option('o', "output-file-path", Required = false, HelpText = "Output file path")]
public string OutputFilePath { get; set; }
[Option('f', "output-file-format", Required = false, HelpText = "Output format [json|text]", Default = "json")]
public new string OutputFileFormat { get; set; } = "json";

[Option('i', "not-indented", Required = false, HelpText = "Remove indentation from json output", Default = false)]
public bool NotIndented { get; set; }

[Option('x', "console-verbosity", Required = false, HelpText = "Console verbosity [high|medium|low|none]", Default = "medium")]
public string ConsoleVerbosityLevel { get; set; }

}

}
}