Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use diff airgap var #468

Merged
merged 1 commit into from
May 6, 2024
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
7 changes: 6 additions & 1 deletion server/modules/elastalert/elastalert.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ func (e *ElastAlertEngine) Init(config module.ModuleConfig) (err error) {
e.sigmaPackageDownloadTemplate = module.GetStringDefault(config, "sigmaPackageDownloadTemplate", DEFAULT_SIGMA_PACKAGE_DOWNLOAD_TEMPLATE)
e.elastAlertRulesFolder = module.GetStringDefault(config, "elastAlertRulesFolder", DEFAULT_ELASTALERT_RULES_FOLDER)
e.rulesFingerprintFile = module.GetStringDefault(config, "rulesFingerprintFile", DEFAULT_RULES_FINGERPRINT_FILE)
e.airgapEnabled = module.GetBoolDefault(config, "airgapEnabled", DEFAULT_AIRGAP_ENABLED)
e.autoEnabledSigmaRules = module.GetStringArrayDefault(config, "autoEnabledSigmaRules", []string{"securityonion-resources+critical", "securityonion-resources+high"})

pkgs := module.GetStringArrayDefault(config, "sigmaRulePackages", []string{"core", "emerging_threats_addon"})
Expand All @@ -146,6 +145,12 @@ func (e *ElastAlertEngine) Init(config module.ModuleConfig) (err error) {
return fmt.Errorf("unable to parse ElastAlert's rulesRepos: %w", err)
}

if e.srv != nil && e.srv.Config != nil {
e.airgapEnabled = e.srv.Config.AirgapEnabled
} else {
e.airgapEnabled = DEFAULT_AIRGAP_ENABLED
}

allow := module.GetStringDefault(config, "allowRegex", DEFAULT_ALLOW_REGEX)
deny := module.GetStringDefault(config, "denyRegex", DEFAULT_DENY_REGEX)

Expand Down
3 changes: 0 additions & 3 deletions server/modules/elastalert/elastalert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ func TestElastAlertModule(t *testing.T) {

err := mod.Init(nil)
assert.NoError(t, err)
assert.False(t, mod.airgapEnabled)

err = mod.Start()
assert.NoError(t, err)
Expand Down Expand Up @@ -538,13 +537,11 @@ func TestLoadSigmaPackagesFromDisks(t *testing.T) {
// Setting up mocks for each expected file read, except for the "fake" package to simulate an error
for _, pkg := range pkgs[:len(pkgs)-1] {
expectedFilePath := airgapBasePath + "sigma_" + pkg + ".zip"
//mio.EXPECT().Join(airgapBasePath, "sigma_"+pkg+".zip").Return(expectedFilePath)
mio.EXPECT().ReadFile(expectedFilePath).Return([]byte("mocked data for "+pkg), nil)
}

// Simulating an error for the 'fake' package
fakeFilePath := airgapBasePath + "sigma_fake.zip"
//mio.EXPECT().JoinPath(airgapBasePath, "sigma_fake.zip").Return(fakeFilePath)
mio.EXPECT().ReadFile(fakeFilePath).Return(nil, errors.New("file not found"))

engine := ElastAlertEngine{
Expand Down
1 change: 0 additions & 1 deletion server/modules/strelka/strelka_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ func TestStrelkaModule(t *testing.T) {

err := mod.Init(nil)
assert.NoError(t, err)
assert.False(t, mod.autoUpdateEnabled)

err = mod.Start()
assert.NoError(t, err)
Expand Down
Loading