Skip to content

Commit

Permalink
Merge pull request #163 from coreruleset/remove-unused-parameters
Browse files Browse the repository at this point in the history
chore: remove unused function parameters
  • Loading branch information
fzipi authored Jul 9, 2024
2 parents 7865464 + 92343a0 commit 3c14106
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
8 changes: 4 additions & 4 deletions cmd/regex_compare.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func performCompare(processAll bool, ctx *processors.Context) error {
if err != nil && len(chainOffsetString) > 0 {
return errors.New("failed to match chain offset. Value must not be larger than 255")
}
regex := runAssemble(filePath, ctx)
regex := runAssemble(filePath)
err = processRegexForCompare(id, uint8(chainOffset), regex, ctx)
if err != nil && errors.Is(err, &ComparisonError{}) {
failed = true
Expand All @@ -154,7 +154,7 @@ func performCompare(processAll bool, ctx *processors.Context) error {
return &ComparisonError{}
}
} else {
regex := runAssemble(path.Join(ctx.RootContext().AssemblyDir(), ruleValues.fileName), ctx)
regex := runAssemble(path.Join(ctx.RootContext().AssemblyDir(), ruleValues.fileName))
return processRegexForCompare(ruleValues.id, ruleValues.chainOffset, regex, ctx)
}
return nil
Expand All @@ -177,7 +177,7 @@ func processRegexForCompare(ruleId string, chainOffset uint8, regex string, ctxt
logger.Debug().Msgf("Processing regex-assembly file %s", filePath)

currentRegex := readCurrentRegex(filePath, ruleId, chainOffset)
return compareRegex(filePath, ruleId, chainOffset, regex, currentRegex)
return compareRegex(ruleId, regex, currentRegex)
}

func readCurrentRegex(filePath string, ruleId string, chainOffset uint8) string {
Expand Down Expand Up @@ -220,7 +220,7 @@ func readCurrentRegex(filePath string, ruleId string, chainOffset uint8) string
return found[0][2]
}

func compareRegex(filePath string, ruleId string, chainOffset uint8, generatedRegex string, currentRegex string) error {
func compareRegex(ruleId string, generatedRegex string, currentRegex string) error {
if currentRegex == generatedRegex {
fmt.Println("Regex of", ruleId, "has not changed")
return nil
Expand Down
5 changes: 2 additions & 3 deletions cmd/regex_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,7 @@ func performUpdate(processAll bool, ctx *processors.Context) {
}
}

func runAssemble(filePath string, ctx *processors.Context) string {
// FIXME: duplicated in generate.go
func runAssemble(filePath string) string {
rootContext := context.New(rootValues.workingDirectory.String(), rootValues.configurationFileName.String())
ctxt := processors.NewContext(rootContext)
assembler := operators.NewAssembler(ctxt)
Expand Down Expand Up @@ -158,7 +157,7 @@ func runAssemble(filePath string, ctx *processors.Context) string {

func processRule(ruleId string, chainOffset uint8, dataFilePath string, ctxt *processors.Context) {
logger.Info().Msgf("Processing %s, chain offset %d", ruleId, chainOffset)
regex := runAssemble(dataFilePath, ctxt)
regex := runAssemble(dataFilePath)

rulePrefix := ruleId[:3]
matches, err := filepath.Glob(fmt.Sprintf("%s/*-%s-*", ctxt.RootContext().RulesDir(), rulePrefix))
Expand Down

0 comments on commit 3c14106

Please sign in to comment.