From 291e936b76ad30a974d5e14a2ee6283061e30bc5 Mon Sep 17 00:00:00 2001 From: zhizhchienko0162 <43669201+zhizhchienko0162@users.noreply.github.com> Date: Tue, 25 Jan 2022 11:47:15 +0300 Subject: [PATCH] add file support without $schema for sarif vscode extension and change default permission for out sarif file (#40) * add file support without $schema for sarif vscode extension https://github.com/microsoft/sarif-vscode-extension/issues/169 * change default permission for out sarif file * replace printSchema with includeSchema --- v2/sarif/sarif.go | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/v2/sarif/sarif.go b/v2/sarif/sarif.go index b9a0c16..8e74627 100644 --- a/v2/sarif/sarif.go +++ b/v2/sarif/sarif.go @@ -28,11 +28,17 @@ type Report struct { } // New Creates a new Report or returns an error -func New(version Version) (*Report, error) { - schema, err := getVersionSchema(version) - if err != nil { - return nil, err - } +func New(version Version, includeSchema... bool) (*Report, error) { + schema := "" + + if len(includeSchema) == 0 || includeSchema[0] { + var err error + + schema, err = getVersionSchema(version) + if err != nil { + return nil, err + } + } return &Report{ Version: string(version), Schema: schema, @@ -83,7 +89,7 @@ func getVersionSchema(version Version) (string, error) { // WriteFile will write the report to a file using a pretty formatter func (sarif *Report) WriteFile(filename string) error { - file, err := os.OpenFile(filename, os.O_CREATE|os.O_WRONLY, os.ModeAppend) + file, err := os.OpenFile(filename, os.O_CREATE|os.O_WRONLY, 0644) if err != nil { return err }