Skip to content

Commit

Permalink
Merge pull request #100 from losisin/feature/gosec-and-bearer
Browse files Browse the repository at this point in the history
feature: scan code with bearer and gosec
  • Loading branch information
losisin authored Nov 11, 2024
2 parents cf67d96 + 82462e6 commit e45ac01
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 3 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ jobs:
skip-cache: true
- name: Check code
run: make check
- name: Run Gosec Security Scanner
uses: securego/[email protected]
with:
args: ./...
- name: Bearer
uses: bearer/bearer-action@v2
with:
scanner: secrets,sast
diff: true
- name: Run tests
run: make test-all
- name: Install plugin
Expand Down
5 changes: 3 additions & 2 deletions pkg/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"os"
"path/filepath"
"strings"

"gopkg.in/yaml.v3"
Expand Down Expand Up @@ -37,7 +38,7 @@ func GenerateJsonSchema(config *Config) error {

// Iterate over the input YAML files
for _, filePath := range config.Input {
content, err := os.ReadFile(filePath)
content, err := os.ReadFile(filepath.Clean(filePath))
if err != nil {
return errors.New("error reading YAML file(s)")
}
Expand Down Expand Up @@ -110,7 +111,7 @@ func GenerateJsonSchema(config *Config) error {

// Write the JSON schema to the output file
outputPath := config.OutputPath
if err := os.WriteFile(outputPath, jsonBytes, 0644); err != nil {
if err := os.WriteFile(outputPath, jsonBytes, 0600); err != nil {
return errors.New("error writing schema to file")
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func TestGenerateJsonSchema(t *testing.T) {
templateSchemaFile: "../testdata/full.schema.json",
},
{
name: "full json schema",
name: "noAdditionalProperties",
config: &Config{
Draft: 2020,
Indent: 4,
Expand Down
5 changes: 5 additions & 0 deletions testdata/anchors.schema.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"$id": "https://example.com/schema",
"$ref": "schema/product.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"additionalProperties": true,
"description": "Schema for Helm values",
"properties": {
"app": {
"properties": {
Expand All @@ -20,5 +24,6 @@
"type": "object"
}
},
"title": "Helm Values Schema",
"type": "object"
}
5 changes: 5 additions & 0 deletions testdata/basic.schema.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"$id": "https://example.com/schema",
"$ref": "schema/product.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"additionalProperties": true,
"description": "Schema for Helm values",
"properties": {
"empty": {
"type": "null"
Expand Down Expand Up @@ -57,5 +61,6 @@
"type": "array"
}
},
"title": "Helm Values Schema",
"type": "object"
}
5 changes: 5 additions & 0 deletions testdata/meta.schema.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"$id": "https://example.com/schema",
"$ref": "schema/product.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"additionalProperties": true,
"description": "Schema for Helm values",
"properties": {
"fullnameOverride": {
"title": "Full name override",
Expand Down Expand Up @@ -50,5 +54,6 @@
"type": "array"
}
},
"title": "Helm Values Schema",
"type": "object"
}

0 comments on commit e45ac01

Please sign in to comment.