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
10 changes: 5 additions & 5 deletions internal/tracefs/kprobe.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ func RandomGroup(prefix string) (string, error) {
}

// validIdentifier implements the equivalent of a regex match
// against "^[a-zA-Z_][0-9a-zA-Z_]*$".
// against "^[a-zA-Z_][0-9a-zA-Z_-]*$".
//
// Trace event groups, names and kernel symbols must adhere to this set
// of characters. Non-empty, first character must not be a number, all
// characters must be alphanumeric or underscore.
// Trace event groups, names and kernel symbols must adhere to this set of
// characters. Non-empty, first character must not be a number or hyphen, all
// characters must be alphanumeric, underscore or hyphen.
func validIdentifier(s string) bool {
if len(s) < 1 {
return false
Expand All @@ -86,7 +86,7 @@ func validIdentifier(s string) bool {
case c >= 'a' && c <= 'z':
case c >= 'A' && c <= 'Z':
case c == '_':
case i > 0 && c >= '0' && c <= '9':
case i > 0 && (c == '-' || c >= '0' && c <= '9'):

default:
return false
Expand Down
3 changes: 2 additions & 1 deletion internal/tracefs/perf_event_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ func TestValidIdentifier(t *testing.T) {
{"underscore first", "__x64_syscall", false},
{"contains number", "bpf_trace_run1", false},
{"underscore", "_", false},
{"contains dash", "-EINVAL", true},
{"leading dash", "-EINVAL", true},
{"contains number", "all0wed", false},
{"contains dash", "trace-group", false},
}

for _, tt := range tests {
Expand Down