Skip to content
Merged
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
4 changes: 2 additions & 2 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
- "docs/**"

env:
GO_VERSION: 1.23.x
GO_VERSION: 1.24.x
WIX_VERSION: 5.0.0
PYTHON_VERSION: 3.7.9

Expand Down Expand Up @@ -228,7 +228,7 @@ jobs:
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin $GOLANGCI_LINT_VER
env:
GOLANGCI_LINT_VER: v1.61.0
GOLANGCI_LINT_VER: v2.2.2
- name: Lint
shell: bash
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
- "docs/**"

env:
GO_VERSION: 1.23.x
GO_VERSION: 1.24.x
WIX_VERSION: 5.0.0
PYTHON_VERSION: 3.7.9

Expand Down Expand Up @@ -210,7 +210,7 @@ jobs:
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin $GOLANGCI_LINT_VER
env:
GOLANGCI_LINT_VER: v1.61.0
GOLANGCI_LINT_VER: v2.2.2
- name: Lint
shell: bash
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- 'v*'

env:
GO_VERSION: 1.23.x
GO_VERSION: 1.24.x
WIX_VERSION: 5.0.0
PYTHON_VERSION: 3.7.9

Expand Down
54 changes: 31 additions & 23 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,46 +1,54 @@
version: "2"
run:
build-tags:
- cap
- filament
deadline: 10m

linters:
disable-all: true
default: none
enable:
- bodyclose
- errcheck
- goconst
- goprintffuncname
- gosimple
- govet
- gofmt
- ineffassign
- nakedret
- noctx
- nolintlint
- rowserrcheck
- staticcheck
- stylecheck
- typecheck
- unconvert
- unparam
- unused
- whitespace
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
rules:
- linters:
- errcheck
- nolintlint
- staticcheck
path: _test\.go
paths:
- third_party$
- builtin$
- examples$

linters-settings:
gofmt:
simplify: false

issues:
# List of regexps of issue texts to exclude.
#
# But independently of this option we use default exclude patterns,
# it can be disabled by `exclude-use-default: false`.
# To list all excluded by default patterns execute `golangci-lint run --help`
#
exclude-rules:
# Exclude some linters from running on tests files.
- path: _test\.go
linters:
- errcheck
- nolintlint
formatters:
enable:
- gofmt
settings:
gofmt:
simplify: false
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
4 changes: 2 additions & 2 deletions cmd/fibratus/app/rules/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ func createRule(name string) error {
return err
}

n := fmt.Sprintf("%s.yml", strings.Replace(strings.ToLower(name), " ", "_", -1))
n := fmt.Sprintf("%s.yml", strings.ReplaceAll(strings.ToLower(name), " ", "_"))
if tacticID != "" {
n = strings.Replace(strings.ToLower(tactics[tacticID]), " ", "_", -1) + "_" + n
n = strings.ReplaceAll(strings.ToLower(tactics[tacticID]), " ", "_") + "_" + n
}
f, err := os.Create(n)
if err != nil {
Expand Down
4 changes: 1 addition & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,4 @@ require (
gopkg.in/yaml.v2 v2.3.0 // indirect
)

go 1.23.0

toolchain go1.23.1
go 1.24.5
4 changes: 2 additions & 2 deletions pkg/alertsender/eventlog/eventlog.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (s *eventlog) Send(alert alertsender.Alert) error {
// assume alert ID has the UUID format
// where we build the short version by
// taking the first 12 characters
id := strings.Replace(alert.ID, "-", "", -1)
id := strings.ReplaceAll(alert.ID, "-", "")
h := crc32.ChecksumIEEE([]byte(id[:minIDChars]))
// take the lower 16 bits of the CRC32 hash
code = uint16(h & 0xFFFF)
Expand All @@ -86,7 +86,7 @@ func (s *eventlog) Send(alert alertsender.Alert) error {
msg := alert.String(s.config.Verbose)
// trim null characters to avoid
// UTF16PtrFromString complaints
msg = strings.Replace(msg, "\x00", "", -1)
msg = strings.ReplaceAll(msg, "\x00", "")

m, err := windows.UTF16PtrFromString(msg)
if err != nil {
Expand Down
6 changes: 4 additions & 2 deletions pkg/event/marshaller.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ func (js *jsonStream) writeMore() *jsonStream {
}

func (js *jsonStream) shouldWriteMore(i, l int) bool {
//nolint:staticcheck
return !(i == l-1)
}

Expand Down Expand Up @@ -295,9 +296,10 @@ func writeStringSlowPath(stream *jsonStream, i int, s string, valLen int) {

func writeFirstBuf(space []byte, v uint32) []byte {
start := v >> 24
if start == 0 {
switch start {
case 0:
space = append(space, byte(v>>16), byte(v>>8))
} else if start == 1 {
case 1:
space = append(space, byte(v>>8))
}
space = append(space, byte(v))
Expand Down
4 changes: 2 additions & 2 deletions pkg/event/param.go
Original file line number Diff line number Diff line change
Expand Up @@ -706,9 +706,9 @@ func (pars Params) String() string {
case SnakeCase:
sb.WriteString(par.Name + ParamKVDelimiter + par.String())
case DotCase:
sb.WriteString(strings.Replace(par.Name, "_", ".", -1) + ParamKVDelimiter + par.String())
sb.WriteString(strings.ReplaceAll(par.Name, "_", ".") + ParamKVDelimiter + par.String())
case PascalCase:
sb.WriteString(strings.Replace(caser.String(strings.Replace(par.Name, "_", " ", -1)), " ", "", -1) + ParamKVDelimiter + par.String())
sb.WriteString(strings.ReplaceAll(caser.String(strings.ReplaceAll(par.Name, "_", " ")), " ", "") + ParamKVDelimiter + par.String())
case CamelCase:
}
if i != len(pars)-1 {
Expand Down
4 changes: 2 additions & 2 deletions pkg/filter/ql/functions/replace.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (f Replace) Call(args []interface{}) (interface{}, bool) {
if len(args) == 3 {
o := parseString(1, args)
n := parseString(2, args)
return strings.Replace(s, o, n, -1), true
return strings.ReplaceAll(s, o, n), true
}
// apply multiple replacements
repl := s
Expand All @@ -49,7 +49,7 @@ func (f Replace) Call(args []interface{}) (interface{}, bool) {
if !ok {
break
}
repl = strings.Replace(repl, o, n, -1)
repl = strings.ReplaceAll(repl, o, n)
}
return repl, true
}
Expand Down
22 changes: 12 additions & 10 deletions pkg/filter/ql/lexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,15 +326,16 @@ func (s *scanner) scanString() (tok token, pos int, lit string) {
s.r.unread()
_, pos = s.r.curr()

var err error
lit, err = ScanString(s.r)
if err == errBadString {
lit, err := ScanString(s.r)
switch err {
case errBadString:
return Badstr, pos, lit
} else if err == errBadEscape {
case errBadEscape:
_, pos = s.r.curr()
return Badstr, pos, lit
default:
return Str, pos, lit
}
return Str, pos, lit
}

var errBadString = errors.New("bad string")
Expand All @@ -358,15 +359,16 @@ func ScanString(r io.RuneScanner) (string, error) {
// If the next character is an escape then write the escaped char.
// If it's not a valid escape then return an error.
ch1, _, _ := r.ReadRune()
if ch1 == 'n' {
switch ch1 {
case 'n':
_, _ = buf.WriteRune('\n')
} else if ch1 == '\\' {
case '\\':
_, _ = buf.WriteRune('\\')
} else if ch1 == '"' {
case '"':
_, _ = buf.WriteRune('"')
} else if ch1 == '\'' {
case '\'':
_, _ = buf.WriteRune('\'')
} else {
default:
return string(ch0) + string(ch1), errBadEscape
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion pkg/ps/snapshotter_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ func TestFindQueryOS(t *testing.T) {
assert.Equal(t, filepath.Join(os.Getenv("windir"), "notepad.exe"), proc.Cmdline)
assert.True(t, len(proc.Envs) > 0)
assert.Contains(t, proc.Cwd, "fibratus\\pkg\\ps")
assert.Equal(t, uint32(1), proc.SessionID)
assert.True(t, proc.SessionID > 0)
assert.Equal(t, "HIGH", proc.TokenIntegrityLevel)

wts, err := sys.LookupActiveWTS()
Expand Down
2 changes: 1 addition & 1 deletion pkg/sys/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func EnumDevices() []Driver {
continue
}
dev := syscall.UTF16ToString(filename)
drv.Filename = strings.Replace(dev, "\\SystemRoot", os.Getenv("SYSTEMROOT"), -1)
drv.Filename = strings.Replace(dev, "\\SystemRoot", os.Getenv("SYSTEMROOT"), 1)
drivers[i] = drv
}
return drivers
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/key/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func Format(key string) (Key, string) {
if strings.HasSuffix(sid, "_Classes") {
return CurrentUser, "Software\\Classes\\" + path[n+1:]
}
return CurrentUser, strings.Replace(path[n+1:], "_Classes", "Software\\Classes", -1)
return CurrentUser, strings.Replace(path[n+1:], "_Classes", "Software\\Classes", 1)
case sid == loggedSID:
if len(path) == len(loggedSID) {
return CurrentUser, ""
Expand Down
Loading