Skip to content
Merged

Fuzzy #205

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions .github/workflows/fuzz.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,34 @@ on: [pull_request]
jobs:
Fuzzing:
runs-on: ubuntu-latest
permissions:
security-events: write
steps:
- name: Build Fuzzers
id: build
uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master
with:
oss-fuzz-project-name: 'gonids'
language: go
dry-run: false
- name: Run Fuzzers
uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master
with:
oss-fuzz-project-name: 'gonids'
language: go
fuzz-seconds: 600
dry-run: false
output-sarif: true
- name: Upload Crash
uses: actions/upload-artifact@v1
if: failure()
uses: actions/upload-artifact@v4
if: failure() && steps.build.outcome == 'success'
with:
name: artifacts
path: ./out/artifacts
- name: Upload Sarif
if: always() && steps.build.outcome == 'success'
uses: github/codeql-action/upload-sarif@v3
with:
# Path to SARIF file relative to the root of the repository
sarif_file: cifuzz-sarif/results.sarif
checkout_path: cifuzz-sarif
2 changes: 1 addition & 1 deletion lex.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ func lexProtocol(l *lexer) stateFn {
case r == ' ':
l.emit(itemProtocol, true)
return lexSourceAddress
case !(unicode.IsLetter(r) || unicode.IsDigit(r) || (l.len() > 0 && r == '-')):
case !unicode.IsLetter(r) && !unicode.IsDigit(r) && l.len() > 0 && r != '-':
return l.errorf("invalid character %q for a rule protocol", r)
}
}
Expand Down
4 changes: 2 additions & 2 deletions parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func parseContent(content string) ([]byte, error) {

b = hexRE.ReplaceAllStringFunc(b,
func(h string) string {
r, err := hex.DecodeString(strings.Replace(strings.Trim(h, "|"), " ", "", -1))
r, err := hex.DecodeString(strings.ReplaceAll(strings.Trim(h, "|"), " ", ""))
if err != nil {
panic("invalid hexRE regexp")
}
Expand Down Expand Up @@ -408,7 +408,7 @@ func unquote(s string) string {
if strings.IndexByte(s, '"') < 0 {
return s
}
return strings.Replace(s, `\"`, `"`, -1)
return strings.ReplaceAll(s, `\"`, `"`)
}

func inSlice(str string, strings []string) bool {
Expand Down
2 changes: 1 addition & 1 deletion rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ func (p PCRE) String() string {

// escape quote signs, if necessary
if bytes.IndexByte(pattern, '"') > -1 {
pattern = bytes.Replace(pattern, []byte(`"`), []byte(`\"`), -1)
pattern = bytes.ReplaceAll(pattern, []byte(`"`), []byte(`\"`))
}

var s strings.Builder
Expand Down