Skip to content

Global tool throws unhandled exception for empty file #236

@jhoak

Description

@jhoak

Describe the bug
When running DevSkim on an empty text or powershell file, the tool exits and spits out the stack trace.

To Reproduce
Steps to reproduce the behavior:

  1. Create a new empty file
  2. Run devskim analyze
  3. See the error.

Expected behavior
Exit the tool with no messages.

Screenshots
image
Stack trace I received:
Unhandled exception. System.AggregateException: One or more errors occurred. (Too many bytes extracted, exceeding limit.)
---> System.OverflowException: Too many bytes extracted, exceeding limit.
at Microsoft.CST.OpenSource.RecursiveExtractor.Extractor.CheckResourceGovernor(Int64 additionalBytes)
at Microsoft.CST.OpenSource.RecursiveExtractor.Extractor.ExtractFile(FileEntry fileEntry, Boolean parallel)
at Microsoft.CST.OpenSource.RecursiveExtractor.Extractor.ExtractFile(String filename, Boolean parallel)+MoveNext()
at System.Collections.Concurrent.Partitioner.DynamicPartitionerForIEnumerable1.InternalPartitionEnumerable.GrabChunk_Buffered(KeyValuePair2[] destArray, Int32 requestedChunkSize, Int32& actualNumElementsGrabbed)
at System.Collections.Concurrent.Partitioner.DynamicPartitionerForIEnumerable1.InternalPartitionEnumerator.GrabNextChunk(Int32 requestedChunkSize) at System.Collections.Concurrent.Partitioner.DynamicPartitionEnumerator_Abstract2.MoveNext()
at System.Threading.Tasks.Parallel.<>c__DisplayClass44_02.<PartitionerForEachWorker>b__1(IEnumerator& partitionState, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion) --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw(Exception source) at System.Threading.Tasks.Parallel.<>c__DisplayClass44_02.b__1(IEnumerator& partitionState, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
at System.Threading.Tasks.TaskReplicator.Replica1.ExecuteAction(Boolean& yieldedBeforeCompletion) at System.Threading.Tasks.TaskReplicator.Replica.Execute() --- End of inner exception stack trace --- at System.Threading.Tasks.TaskReplicator.Run[TState](ReplicatableUserAction1 action, ParallelOptions options, Boolean stopOnFirstFailure)
at System.Threading.Tasks.Parallel.PartitionerForEachWorker[TSource,TLocal](Partitioner1 source, ParallelOptions parallelOptions, Action1 simpleBody, Action2 bodyWithState, Action3 bodyWithStateAndIndex, Func4 bodyWithStateAndLocal, Func5 bodyWithEverything, Func1 localInit, Action1 localFinally)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw(Exception source)
at System.Threading.Tasks.Parallel.ThrowSingleCancellationExceptionOrOtherException(ICollection exceptions, CancellationToken cancelToken, Exception otherException)
at System.Threading.Tasks.Parallel.PartitionerForEachWorker[TSource,TLocal](Partitioner1 source, ParallelOptions parallelOptions, Action1 simpleBody, Action2 bodyWithState, Action3 bodyWithStateAndIndex, Func4 bodyWithStateAndLocal, Func5 bodyWithEverything, Func1 localInit, Action1 localFinally)
at System.Threading.Tasks.Parallel.ForEachWorker[TSource,TLocal](IEnumerable1 source, ParallelOptions parallelOptions, Action1 body, Action2 bodyWithState, Action3 bodyWithStateAndIndex, Func4 bodyWithStateAndLocal, Func5 bodyWithEverything, Func1 localInit, Action1 localFinally)
at System.Threading.Tasks.Parallel.ForEach[TSource](IEnumerable1 source, Action1 body)
at Microsoft.DevSkim.CLI.Commands.AnalyzeCommand.RunFileEntries(IEnumerable`1 fileListing, StreamWriter outputStreamWriter) in D:\a\1\s\DevSkim-DotNet\Microsoft.DevSkim.CLI\Commands\AnalyzeCommand.cs:line 287
at Microsoft.DevSkim.CLI.Commands.AnalyzeCommand.Run() in D:\a\1\s\DevSkim-DotNet\Microsoft.DevSkim.CLI\Commands\AnalyzeCommand.cs:line 137
at Microsoft.DevSkim.CLI.Commands.AnalyzeCommand.<>c__DisplayClass1_0.b__0() in D:\a\1\s\DevSkim-DotNet\Microsoft.DevSkim.CLI\Commands\AnalyzeCommand.cs:line 97
at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
at Microsoft.DevSkim.CLI.Program.Main(String[] args) in D:\a\1\s\DevSkim-DotNet\Microsoft.DevSkim.CLI\Program.cs:line 14

Versions(please complete the following information):

  • OS: Windows 10 version 2004
  • Devskim Version 0.4.192 - global tool (i.e., Microsoft.CST.DevSkim.CLI)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions