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
2 changes: 1 addition & 1 deletion g4/SecLangParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ metadata_action_with_params:
| ACTION_SEVERITY # ACTION_SEVERITY
| ACTION_TAG # ACTION_TAG
| ACTION_VER # ACTION_VER
| ACTION_LOG_DATA # ACTION_LOG_DATA
;

disruptive_action_with_params:
Expand All @@ -428,7 +429,6 @@ non_disruptive_action_with_params:
| ACTION_EXPIRE_VAR
| ACTION_DEPRECATE_VAR
| ACTION_INITCOL
| ACTION_LOG_DATA
| ACTION_PREPEND
| ACTION_SANITISE_ARG
| ACTION_SANITISE_MATCHED_BYTES
Expand Down
5 changes: 5 additions & 0 deletions listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type ParserResult struct {
SetvarCollections []string `yaml:"setvar_collections"`
SetvarNames []string `yaml:"setvar_names"`
SetvarOperations []string `yaml:"setvar_operations"`
LogdataActionCount int `yaml:"logdata_action_count"`
}

type TreeShapeListener struct {
Expand Down Expand Up @@ -220,3 +221,7 @@ func (l *TreeShapeListener) EnterTransformation_action_value(ctx *parser.Transfo
func (l *TreeShapeListener) EnterComment_block(ctx *parser.Comment_blockContext) {
l.results.CommentsBlocks++
}

func (l *TreeShapeListener) EnterACTION_LOG_DATA(ctx *parser.ACTION_LOG_DATAContext) {
l.results.LogdataActionCount += 1
}
342 changes: 192 additions & 150 deletions parser/seclang_parser.go

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions parser/seclangparser_base_listener.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions parser/seclangparser_listener.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

555 changes: 288 additions & 267 deletions src/seclang_parser/SecLangParser.py

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions src/seclang_parser/SecLangParserListener.py
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,15 @@ def exitACTION_VER(self, ctx:SecLangParser.ACTION_VERContext):
pass


# Enter a parse tree produced by SecLangParser#ACTION_LOG_DATA.
def enterACTION_LOG_DATA(self, ctx:SecLangParser.ACTION_LOG_DATAContext):
pass

# Exit a parse tree produced by SecLangParser#ACTION_LOG_DATA.
def exitACTION_LOG_DATA(self, ctx:SecLangParser.ACTION_LOG_DATAContext):
pass


# Enter a parse tree produced by SecLangParser#disruptive_action_with_params.
def enterDisruptive_action_with_params(self, ctx:SecLangParser.Disruptive_action_with_paramsContext):
pass
Expand Down
6 changes: 5 additions & 1 deletion src/seclang_parser/listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class ParserResult:
setvar_collections: list[str] = field(default_factory=list)
setvar_names: list[str] = field(default_factory=list)
setvar_operations: list[str] = field(default_factory=list)
logdata_action_count: int = 0


class TreeShapeListener(SecLangParserListener):
Expand Down Expand Up @@ -148,4 +149,7 @@ def enterTransformation_action_value(self, ctx: SecLangParser.Transformation_act
self.results.directive_values.append(ctx.getText())

def enterComment_block(self, ctx: SecLangParser.Comment_blockContext):
self.results.comment_blocks += 1
self.results.comment_blocks += 1

def enterACTION_LOG_DATA(self, ctx):
self.results.logdata_action_count += 1
1 change: 1 addition & 0 deletions testdata/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -492,3 +492,4 @@ check_output_tests:
directive_values:
- "none"
- "%{tx.warning_anomaly_score}"
logdata_action_count: 1