Skip to content

Commit

Permalink
add GoSec and Golangci-lint
Browse files Browse the repository at this point in the history
  • Loading branch information
dmolik committed Aug 27, 2022
1 parent bf980b3 commit fc6dc45
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 2 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/gosec.yaml
@@ -0,0 +1,25 @@
on: [push, pull_request]
name: GoSec
jobs:
gosec:
strategy:
matrix:
go-version: [1.18.x]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v3
- name: Security Scan
uses: securego/gosec@master
with:
args: '-fmt sarif -out results.sarif ./...'
- name: Upload SARIF file
uses: github/codeql-action/upload-sarif@v2
with:
# Path to SARIF file relative to the root of the repository
sarif_file: results.sarif
21 changes: 21 additions & 0 deletions .github/workflows/lint.yaml
@@ -0,0 +1,21 @@
on: [push, pull_request]
name: Lint
jobs:
lint:
strategy:
matrix:
go-version: [1.18.x]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.49
args: --tests=false
5 changes: 3 additions & 2 deletions mapstructure.go
Expand Up @@ -590,6 +590,7 @@ func (d *Decoder) decodeString(name string, data interface{}, val reflect.Value)
case reflect.Uint8:
var uints []uint8
if dataKind == reflect.Array {
// nolint:gosimple
uints = make([]uint8, dataVal.Len(), dataVal.Len())
for i := range uints {
uints[i] = dataVal.Index(i).Interface().(uint8)
Expand Down Expand Up @@ -939,12 +940,12 @@ func (d *Decoder) decodeMapFromStruct(name string, dataVal reflect.Value, val re
if tagValue[:index] == "-" {
continue
}
// If "omitempty" is specified in the tag, it ignores empty values.
// nolint:gosimple // If "omitempty" is specified in the tag, it ignores empty values.
if strings.Index(tagValue[index+1:], "omitempty") != -1 && isEmptyValue(v) {
continue
}

// If "squash" is specified in the tag, we squash the field down.
// nolint:gosimple // If "squash" is specified in the tag, we squash the field down.
squash = squash || strings.Index(tagValue[index+1:], "squash") != -1
if squash {
// When squashing, the embedded type can be a pointer to a struct.
Expand Down

0 comments on commit fc6dc45

Please sign in to comment.