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

Directory issues, print package name, fix options output #384

Merged
merged 1 commit into from
Jan 4, 2023
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
5 changes: 5 additions & 0 deletions src/Shared.CLI/Helpers/PackageDownloader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ public PackageDownloader(PackageURL purl, ProjectManagerFactory projectManagerFa
{
usingTemp = true;
destinationDirectory = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());

if (!Directory.Exists(destinationDirectory))
{
Directory.CreateDirectory(destinationDirectory);
}
}
else
{
Expand Down
3 changes: 3 additions & 0 deletions src/Shared/Helpers/ArchiveHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ public static async Task<string> ExtractArchiveAsync(
dirBuilder.Replace(c, '-'); // CodeQL [cs/string-concatenation-in-loop] This is a small loop
}

// Extractor does not handle slashes well, so we need to remove them here.
dirBuilder.Replace('/', '-');

string fullTargetPath = Path.Combine(topLevelDirectory, dirBuilder.ToString());

if (!cached)
Expand Down
7 changes: 4 additions & 3 deletions src/oss-detect-cryptography/DetectCryptographyTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ private static async Task Main(string[] args)
sb.Clear();
try
{
sb.AppendLine($"{target}");

List<IssueRecord>? results = null;
if (target.StartsWith("pkg:", StringComparison.InvariantCulture))
{
Expand Down Expand Up @@ -114,7 +116,6 @@ private static async Task Main(string[] args)
else
{
sb.AppendLine("Summary Results:");

sb.AppendLine(Blue("Cryptographic Implementations:"));
IOrderedEnumerable<string>? implementations = results.SelectMany(r => r.Issue.Rule.Tags ?? Array.Empty<string>())
.Distinct()
Expand Down Expand Up @@ -735,8 +736,8 @@ private static void ShowUsage()
--disable-default-rules do not load default, built-in rules.
--download-directory the directory to download the package to
--use-cache do not download the package if it is already present in the destination directory
--format specify the output format (text|sarifv1|sarifv2). (default is text)
--output-file send the command output to a file instead of stdout
--format specify the output format (text|sarifv1|sarifv2). (default is text) (currently not supported)
--output-file send the command output to a file instead of stdout (currently not supported)
--help show this help message and exit
--version show version of this tool
");
Expand Down