Skip to content

Commit

Permalink
Merge branch 'main' into container
Browse files Browse the repository at this point in the history
  • Loading branch information
l50 committed Aug 15, 2023
2 parents 1da2341 + b62e299 commit 39255f8
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 96 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:

jobs:
codeql:
name: Compute Code Coverage
name: Run CodeQL Security Vulnerability Analysis
runs-on: ubuntu-latest

permissions:
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/nancy.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
---
name: Nancy 3p Vulnerability Scan
on:
push:
pull_request:
types:
- opened
- synchronize

jobs:
nancy:
name: Run nancy to identify 3p go vulnerabilities
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
---
name: Pre-Commit
on:
push:
pull_request:
types:
- opened
- synchronize
# Run once a week (see https://crontab.guru)
schedule:
- cron: "0 0 * * 0"
workflow_dispatch:

jobs:
pre-commit:
name: Update pre-commit hooks and run pre-commit
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/semgrep.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
---
name: 🚨 Semgrep Analysis
on:
push:
pull_request:

types:
- opened
- synchronize
jobs:
semgrep:
name: Evaluate code for vulnerabilities
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
name: Tests
on:
pull_request:
push:

types:
- opened
- synchronize
jobs:
tests:
name: Run tests - includes pre-commit hooks and determining code coverage %
Expand Down
20 changes: 0 additions & 20 deletions pkg/blocks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -481,26 +481,6 @@ returns it as a string.

---

### JSONString(any)

```go
JSONString(any) string, error
```

JSONString returns a string representation of an object in JSON format.

**Parameters:**

in: An object of any type.

**Returns:**

string: A string representing the object in JSON format.

error: An error if the object cannot be encoded as JSON.

---

### LoadTTP(string, afero.Fs, *TTPExecutionConfig, []string)

```go
Expand Down
22 changes: 0 additions & 22 deletions pkg/blocks/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ THE SOFTWARE.
package blocks

import (
"encoding/json"
"errors"
"fmt"
"io/fs"
Expand Down Expand Up @@ -178,27 +177,6 @@ func FetchEnv(environ map[string]string) []string {
return envSlice
}

// JSONString returns a string representation of an object in JSON format.
//
// **Parameters:**
//
// in: An object of any type.
//
// **Returns:**
//
// string: A string representing the object in JSON format.
//
// error: An error if the object cannot be encoded as JSON.
func JSONString(in any) (string, error) {
out, err := json.Marshal(in)
if err != nil {
logging.Logger.Sugar().Errorw(err.Error(), zap.Error(err))
return "", err
}

return fmt.Sprintf("'%s'", string(out)), nil
}

// Contains checks if a key exists in a map.
//
// **Parameters:**
Expand Down
45 changes: 0 additions & 45 deletions pkg/blocks/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,51 +227,6 @@ func TestFetchEnv(t *testing.T) {
}
}

func TestJSONString(t *testing.T) {
type TestStruct struct {
Field1 string `json:"field1"`
Field2 int `json:"field2"`
}

tests := []struct {
name string
input any
expected string
wantErr bool
}{
{
name: "Valid input",
input: TestStruct{
Field1: "test",
Field2: 123,
},
expected: "'{\"field1\":\"test\",\"field2\":123}'",
wantErr: false,
},
{
name: "Invalid input",
input: make(chan int),
expected: "",
wantErr: true,
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := blocks.JSONString(tt.input)

if (err != nil) != tt.wantErr {
t.Errorf("error running JSONString(): %v, wantErr %v", err, tt.wantErr)
return
}

if got != tt.expected {
t.Errorf("unexpected output from JSONString() got = %v, expected %v", got, tt.expected)
}
})
}
}

func TestContains(t *testing.T) {
tests := []struct {
name string
Expand Down

0 comments on commit 39255f8

Please sign in to comment.