public SarifLogger( string outputFilePath, bool verbose, IEnumerable <string> analysisTargets, bool computeTargetsHash) { Verbose = verbose; _fileStream = new FileStream(outputFilePath, FileMode.Create, FileAccess.Write, FileShare.None); _textWriter = new StreamWriter(_fileStream); _jsonTextWriter = new JsonTextWriter(_textWriter); // for debugging it is nice to have the following line added. _jsonTextWriter.Formatting = Newtonsoft.Json.Formatting.Indented; _issueLogJsonWriter = new IssueLogJsonWriter(_jsonTextWriter); Version version = this.GetType().Assembly.GetName().Version; ToolInfo toolInfo = new ToolInfo(); toolInfo.ToolName = "BinSkim"; toolInfo.ProductVersion = version.Major.ToString() + "." + version.Minor.ToString(); toolInfo.FileVersion = version.ToString(); toolInfo.FullVersion = toolInfo.ProductVersion + " beta pre-release"; RunInfo runInfo = new RunInfo(); runInfo.AnalysisTargets = new List <FileReference>(); foreach (string target in analysisTargets) { var fileReference = new FileReference() { Uri = target.CreateUriForJsonSerialization(), }; if (computeTargetsHash) { string sha256Hash = PE.ComputeSha256Hash(target) ?? "[could not compute file hash]"; fileReference.Hashes = new List <Hash>(new Hash[] { new Hash() { Value = sha256Hash, Algorithm = "SHA-256", } }); } runInfo.AnalysisTargets.Add(fileReference); } _issueLogJsonWriter.WriteToolAndRunInfo(toolInfo, runInfo); }