Skip to content

Commit

Permalink
add file support without $schema for sarif vscode extension and chang…
Browse files Browse the repository at this point in the history
…e default permission for out sarif file (#40)

* add file support without $schema for sarif vscode extension
microsoft/sarif-vscode-extension#169

* change default permission for out sarif file

* replace printSchema with includeSchema
  • Loading branch information
glebziz authored Jan 25, 2022
1 parent 0666226 commit 291e936
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions v2/sarif/sarif.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 291e936

Please sign in to comment.