-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from simeonmiteff/add-reference
Parse reference options int Rule.References[] and expose classtype
- Loading branch information
Showing
3 changed files
with
43 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package suricataparser | ||
|
||
import ( | ||
"errors" | ||
"strings" | ||
) | ||
|
||
type Reference struct { | ||
Type string | ||
Ref string | ||
} | ||
|
||
// ParseReference from raw string | ||
func ParseReference(reference string) (*Reference, error) { | ||
if reference == "" { | ||
return nil, errors.New("reference is never empty") | ||
} | ||
parts := strings.SplitN(reference, ",", 2) | ||
if len(parts) != 2 { | ||
return nil, errors.New("reference should be type,ref") | ||
} | ||
return &Reference{Type: parts[0], Ref: parts[1]}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters