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

2.4.60 #390

Merged
merged 191 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
191 commits
Select commit Hold shift + click to select a range
bec7b5b
WIP: Demo + CleanUp
coreyogburn Aug 25, 2023
648e2b5
WIP: More Detections Work
coreyogburn Sep 1, 2023
4541e9b
WIP: Suricata Rule Parsing
coreyogburn Sep 8, 2023
f4d1eaf
WIP: alerts
coreyogburn Sep 20, 2023
13c03c4
WIP: Various improvements
coreyogburn Sep 21, 2023
9ab8827
WIP: Tests
coreyogburn Sep 22, 2023
7baf618
WIP: Modulaization and Elastic Index Change
coreyogburn Sep 25, 2023
a411b08
WIP: Tests
coreyogburn Sep 26, 2023
ea0e6f5
WIP: Sync Community Detections
coreyogburn Sep 29, 2023
654b438
WIP: Community Detections Sync
coreyogburn Sep 29, 2023
5cb9925
Service Account Ctx, Community Rules, permissions
coreyogburn Oct 3, 2023
c4c66fb
WIP: GetAll that gets all
coreyogburn Oct 5, 2023
77ecfb0
WIP: Tightening Suricata Bolts
coreyogburn Oct 11, 2023
341a563
Early implementation of ElastAlert's DetectionEngine.
coreyogburn Oct 19, 2023
1c849e3
WIP: ElastAlert
coreyogburn Oct 26, 2023
064f4e7
WIP ElastAlert Improvements
coreyogburn Nov 6, 2023
6328360
WIP: License Text, Linting
coreyogburn Nov 7, 2023
db72d14
WIP: Overrides in the Tuning Tab
coreyogburn Nov 16, 2023
a9cba2f
WIP: Save Overrides
coreyogburn Nov 27, 2023
4111311
WIP: Overrides
coreyogburn Nov 28, 2023
8313d92
WIP: Track Options, Override UpdatedAt
coreyogburn Nov 28, 2023
0b14887
WIP: ElastAlert enable new community detections
coreyogburn Nov 30, 2023
5adb48a
WIP: Post-Rebase go mod tidy
coreyogburn Dec 19, 2023
679479c
WIP: ElastAlertEngine Tests
coreyogburn Dec 20, 2023
c8bb0cb
WIP: Yara Parser
coreyogburn Dec 29, 2023
3c8f628
WIP: Bulk Actions, Removal of Date Range from Detections Search
coreyogburn Jan 11, 2024
5eafeb9
WIP: Fix for removed Date Range from Detections
coreyogburn Jan 11, 2024
64984cd
WIP: Async Bulk Operations
coreyogburn Jan 17, 2024
594c2b8
WIP: Strelka/Yara Community Rule Import, ElastAlert now translates wi…
coreyogburn Jan 29, 2024
7549c63
WIP: Fix Suricata Parser Bug
coreyogburn Jan 30, 2024
c4d9fe1
WIP: Cleanup
coreyogburn Jan 31, 2024
abd6ba0
WIP: First pass at including sigma-cli in the dockerfile
coreyogburn Jan 31, 2024
c6502fd
WIP: Remove Custom Config, Suricata Community Rules Start Disabled
coreyogburn Feb 1, 2024
17f3d30
WIP: Fix Sigma Shebang, Copy Site-Packages to New Location
coreyogburn Feb 1, 2024
529a15f
Merge pull request #333 from Security-Onion-Solutions/cogburn/detecti…
coreyogburn Feb 1, 2024
587b9b3
WIP: Removed Hardcoded Config Values
coreyogburn Feb 2, 2024
1fba19b
Merge pull request #334 from Security-Onion-Solutions/cogburn/detecti…
coreyogburn Feb 2, 2024
1b33e45
WIP: Detection History
coreyogburn Feb 2, 2024
93bdb05
Merge pull request #335 from Security-Onion-Solutions/cogburn/detecti…
coreyogburn Feb 2, 2024
b592063
WIP: UI Changes
coreyogburn Feb 6, 2024
b1e8346
WIP: Detection Tags, Ruleset, and Language
coreyogburn Feb 6, 2024
7aecfc2
Revise Quicklinks
defensivedepth Feb 7, 2024
d4c8f5c
Add support for sigma pipelines
defensivedepth Feb 8, 2024
449787d
Merge remote-tracking branch 'origin/cogburn/detections_playbooks' in…
defensivedepth Feb 8, 2024
3c02be7
WIP: Reworked UI
coreyogburn Feb 8, 2024
ed5e0e5
Merge pull request #338 from Security-Onion-Solutions/cogburn/detecti…
coreyogburn Feb 8, 2024
460c643
WIP: UI Updates
coreyogburn Feb 8, 2024
47ee245
WIP: Fix References
coreyogburn Feb 9, 2024
64143e7
WIP: License, Rule Extracted Data
coreyogburn Feb 9, 2024
3e68b34
Merge remote-tracking branch 'origin/cogburn/detections_playbooks' in…
defensivedepth Feb 10, 2024
1f9d470
WIP: Updated Tests to Include License Checks
coreyogburn Feb 12, 2024
c324aa7
Merge pull request #341 from Security-Onion-Solutions/cogburn/detecti…
coreyogburn Feb 12, 2024
11f6a8d
Titles for Detections columns
defensivedepth Feb 13, 2024
a05fce1
Dont enable Sigma rules upon import
defensivedepth Feb 13, 2024
d56518b
WIP: Demo + CleanUp
coreyogburn Aug 25, 2023
52d30c7
WIP: More Detections Work
coreyogburn Sep 1, 2023
8963f20
WIP: Suricata Rule Parsing
coreyogburn Sep 8, 2023
1baa496
WIP: alerts
coreyogburn Sep 20, 2023
11e1b09
WIP: Various improvements
coreyogburn Sep 21, 2023
d46987d
WIP: Tests
coreyogburn Sep 22, 2023
a239976
WIP: Modulaization and Elastic Index Change
coreyogburn Sep 25, 2023
1f61e40
WIP: Tests
coreyogburn Sep 26, 2023
04ec7c2
WIP: Sync Community Detections
coreyogburn Sep 29, 2023
3268287
WIP: Community Detections Sync
coreyogburn Sep 29, 2023
e1a9267
Service Account Ctx, Community Rules, permissions
coreyogburn Oct 3, 2023
a9e0e10
WIP: GetAll that gets all
coreyogburn Oct 5, 2023
2774955
WIP: Tightening Suricata Bolts
coreyogburn Oct 11, 2023
af01da5
Early implementation of ElastAlert's DetectionEngine.
coreyogburn Oct 19, 2023
fef8636
WIP: ElastAlert
coreyogburn Oct 26, 2023
59c891a
WIP ElastAlert Improvements
coreyogburn Nov 6, 2023
4cb0d47
WIP: License Text, Linting
coreyogburn Nov 7, 2023
c4320b1
WIP: Overrides in the Tuning Tab
coreyogburn Nov 16, 2023
b18e835
WIP: Save Overrides
coreyogburn Nov 27, 2023
3d0b2a6
WIP: Overrides
coreyogburn Nov 28, 2023
7430141
WIP: Track Options, Override UpdatedAt
coreyogburn Nov 28, 2023
24328d0
WIP: ElastAlert enable new community detections
coreyogburn Nov 30, 2023
05ddbf1
WIP: Post-Rebase go mod tidy
coreyogburn Dec 19, 2023
4029190
WIP: ElastAlertEngine Tests
coreyogburn Dec 20, 2023
38df3b0
WIP: Yara Parser
coreyogburn Dec 29, 2023
67a9bfa
WIP: Bulk Actions, Removal of Date Range from Detections Search
coreyogburn Jan 11, 2024
fea0d27
WIP: Fix for removed Date Range from Detections
coreyogburn Jan 11, 2024
36b6d28
WIP: Async Bulk Operations
coreyogburn Jan 17, 2024
d37e91e
WIP: Strelka/Yara Community Rule Import, ElastAlert now translates wi…
coreyogburn Jan 29, 2024
43f134f
WIP: Fix Suricata Parser Bug
coreyogburn Jan 30, 2024
95b3dee
WIP: Cleanup
coreyogburn Jan 31, 2024
b9efd27
WIP: First pass at including sigma-cli in the dockerfile
coreyogburn Jan 31, 2024
9c6dd15
WIP: Remove Custom Config, Suricata Community Rules Start Disabled
coreyogburn Feb 1, 2024
159ff64
WIP: Fix Sigma Shebang, Copy Site-Packages to New Location
coreyogburn Feb 1, 2024
0f20344
WIP: Removed Hardcoded Config Values
coreyogburn Feb 2, 2024
ac389ef
WIP: Detection History
coreyogburn Feb 2, 2024
21fef2b
WIP: UI Changes
coreyogburn Feb 6, 2024
914e240
WIP: Detection Tags, Ruleset, and Language
coreyogburn Feb 6, 2024
9914a52
WIP: Reworked UI
coreyogburn Feb 8, 2024
88fd8a1
WIP: UI Updates
coreyogburn Feb 8, 2024
0230529
WIP: Fix References
coreyogburn Feb 9, 2024
d375e95
WIP: License, Rule Extracted Data
coreyogburn Feb 9, 2024
4a05909
WIP: Updated Tests to Include License Checks
coreyogburn Feb 12, 2024
a6810b2
WIP: Comments, Permissions
coreyogburn Feb 13, 2024
95fd327
Merge branch 'kilo' into cogburn/detections_playbooks
coreyogburn Feb 13, 2024
124bb75
Merge pull request #348 from Security-Onion-Solutions/cogburn/detecti…
coreyogburn Feb 13, 2024
a603daf
Query parameter can select ActiveTab
coreyogburn Feb 14, 2024
77b7c15
Merge pull request #350 from Security-Onion-Solutions/cogburn/detecti…
coreyogburn Feb 14, 2024
0c262a8
Query parameter can select ActiveTab
coreyogburn Feb 14, 2024
6f3c592
Convert and Test ElastAlert Sigma
coreyogburn Feb 14, 2024
5e806f5
sigmaRulePackages is a string array in the config
coreyogburn Feb 15, 2024
4e9c34e
Tweak Wording
defensivedepth Feb 16, 2024
d8f1414
Switch to Language
defensivedepth Feb 16, 2024
d8d12e0
Merge pull request #351 from Security-Onion-Solutions/patch
defensivedepth Feb 16, 2024
d2979e1
Allow and Deny Regexes per Detection Engine
coreyogburn Feb 16, 2024
0909ad0
Strelka rules are compiled by default but can be disabled
coreyogburn Feb 20, 2024
4df7617
Hide MultiSelect Checkbox unless in Detections
coreyogburn Feb 20, 2024
0942c43
Check for the existence of a template before starting community rule …
coreyogburn Feb 20, 2024
23ef5da
Improvements
coreyogburn Feb 21, 2024
948d6cb
Merge remote-tracking branch 'origin/cogburn/detections_playbooks' in…
defensivedepth Feb 21, 2024
4f27a5b
Merge remote-tracking branch 'origin/2.4/dev' into kilo
defensivedepth Feb 21, 2024
852df88
Merge pull request #353 from Security-Onion-Solutions/kilo
coreyogburn Feb 21, 2024
e73504a
Text change
defensivedepth Feb 22, 2024
e9b00b6
Merge pull request #354 from Security-Onion-Solutions/2.4/detections
defensivedepth Feb 22, 2024
d09207f
New Create Detection Form
coreyogburn Feb 22, 2024
77c8a14
Tests for Each Engine's ExtractDetails()
coreyogburn Feb 23, 2024
e8eb930
Merge pull request #355 from Security-Onion-Solutions/cogburn/detections
coreyogburn Feb 23, 2024
52eb74e
fix broken sigma test
jertel Feb 23, 2024
b5f0e4a
Merge pull request #356 from Security-Onion-Solutions/jertel/detdisable
jertel Feb 23, 2024
fc8ed6d
disable community rule auto updates by default
jertel Feb 23, 2024
e664b0b
Merge pull request #357 from Security-Onion-Solutions/jertel/detdisable
jertel Feb 23, 2024
62ef1e9
FEATURE: Add new SOC action for Process Info Security-Onion-Solutions…
dougburks Feb 26, 2024
1341011
Merge pull request #358 from Security-Onion-Solutions/dougburks-patch-1
dougburks Feb 26, 2024
3dff89e
New Alert Quick Action: Tune Detection
coreyogburn Feb 26, 2024
bcbd0ba
Fix casing of i18n string
coreyogburn Feb 27, 2024
a75c715
Merge pull request #359 from Security-Onion-Solutions/cogburn/tune-de…
coreyogburn Feb 27, 2024
c0d7918
Disable QuickAction Item Until Ready
coreyogburn Feb 27, 2024
6c66ff1
Merge pull request #360 from Security-Onion-Solutions/cogburn/tune-de…
coreyogburn Feb 27, 2024
dacffa8
upgrade kratos
jertel Mar 4, 2024
3d5cd01
Merge pull request #362 from Security-Onion-Solutions/jertel/krup
jertel Mar 4, 2024
d9e878b
switch kratos runtime container to ubuntu
jertel Mar 4, 2024
6fc86fe
switch back to kratos username
jertel Mar 4, 2024
7088059
Merge pull request #363 from Security-Onion-Solutions/jertel/krup
jertel Mar 4, 2024
bc0ee90
Change default test index
defensivedepth Mar 4, 2024
a1b1e5f
Change event.module to sigma
defensivedepth Mar 4, 2024
d5a59a2
Merge pull request #364 from Security-Onion-Solutions/2.4/detections-…
defensivedepth Mar 4, 2024
f49b4b3
Merge pull request #366 from Security-Onion-Solutions/2.4/detections-…
defensivedepth Mar 5, 2024
366c9d7
Fix tests
defensivedepth Mar 5, 2024
985459e
Merge pull request #367 from Security-Onion-Solutions/2.4/detections-…
defensivedepth Mar 5, 2024
e4ec1d5
No More DetectionStore Crossover
coreyogburn Mar 4, 2024
0638c0c
Merge pull request #365 from Security-Onion-Solutions/cogburn/store-i…
coreyogburn Mar 5, 2024
f36614f
Include Comments in Detection History
coreyogburn Mar 5, 2024
794b6a0
Merge pull request #369 from Security-Onion-Solutions/cogburn/detecti…
coreyogburn Mar 5, 2024
eb155de
Add toggle to exclude Detections data
defensivedepth Mar 6, 2024
bb136cf
add feature toggle for detections
jertel Mar 6, 2024
7af8f45
Merge pull request #371 from Security-Onion-Solutions/jertel/det
jertel Mar 6, 2024
5419f23
Merge pull request #370 from Security-Onion-Solutions/2.4/detections-…
defensivedepth Mar 6, 2024
5c301b2
suri pcap improvements
jertel Mar 7, 2024
270edea
suri pcap improvements
jertel Mar 7, 2024
f438394
Merge pull request #372 from Security-Onion-Solutions/jertel/det
jertel Mar 7, 2024
77b6da3
gracefully handle permission errors
jertel Mar 7, 2024
869486d
logging enhancements
jertel Mar 8, 2024
5fcb1c1
Merge pull request #373 from Security-Onion-Solutions/jertel/det
jertel Mar 8, 2024
5022c40
Indicate Clickable Detection Fields
coreyogburn Mar 8, 2024
bf422be
pcap improvements
jertel Mar 8, 2024
ea9b8af
Merge pull request #374 from Security-Onion-Solutions/cogburn/click-t…
coreyogburn Mar 8, 2024
e56960d
"Tune Detections" Only in Alerts
coreyogburn Mar 8, 2024
f08e90f
Merge pull request #376 from Security-Onion-Solutions/cogburn/tune-on…
coreyogburn Mar 8, 2024
21f09a3
Strelka Rule License Fallback
coreyogburn Mar 8, 2024
c99f8ca
Improved Error Granularity Around Strelka Repos
coreyogburn Mar 8, 2024
5d490dc
Merge pull request #377 from Security-Onion-Solutions/cogburn/yara-li…
coreyogburn Mar 8, 2024
4161b89
Merge pull request #375 from Security-Onion-Solutions/jertel/det
jertel Mar 8, 2024
5dcba37
Allow For Zero Strelka Rules Repos
coreyogburn Mar 8, 2024
da65dd9
Merge pull request #378 from Security-Onion-Solutions/cogburn/strelka…
coreyogburn Mar 8, 2024
3367426
improve reboot indicators
jertel Mar 8, 2024
853298e
Merge pull request #379 from Security-Onion-Solutions/jertel/det
jertel Mar 8, 2024
ac24917
allow sensoroni modules to succeed if at least one provided data
jertel Mar 12, 2024
560e352
Merge pull request #380 from Security-Onion-Solutions/jertel/det
jertel Mar 12, 2024
0d1bc24
Bug Fixes and Tweaks
coreyogburn Feb 29, 2024
b759466
JS Unit Tests + Tweaks
coreyogburn Mar 1, 2024
2b86689
Moved override update logic from the detectionhandler to the detectio…
coreyogburn Mar 6, 2024
d409b16
ElasticDetectionStore Tests
coreyogburn Mar 12, 2024
4ed2581
Merge pull request #381 from Security-Onion-Solutions/cogburn/detecti…
coreyogburn Mar 12, 2024
020728e
Fix for jsyaml reference in tests
coreyogburn Mar 12, 2024
f84fc30
Merge pull request #382 from Security-Onion-Solutions/cogburn/jsyaml-…
coreyogburn Mar 12, 2024
9e405b5
Better Defaults in Detection Engines
coreyogburn Mar 12, 2024
9d1ccbe
Merge pull request #383 from Security-Onion-Solutions/cogburn/detecti…
coreyogburn Mar 12, 2024
ed62dc7
Add NIDS Tuning Links back in
defensivedepth Mar 13, 2024
d98a447
Merge pull request #384 from Security-Onion-Solutions/2.4/detections-…
defensivedepth Mar 13, 2024
beb1e70
check bidirectional pcap
jertel Mar 13, 2024
58adedf
Merge pull request #385 from Security-Onion-Solutions/jertel/pcap
jertel Mar 13, 2024
c7f4622
add more logging
jertel Mar 13, 2024
49b4375
Merge pull request #386 from Security-Onion-Solutions/jertel/pcap
jertel Mar 13, 2024
8bd29f4
refactor suri pcap parser for 4x perf gain
jertel Mar 14, 2024
327af87
Merge pull request #387 from Security-Onion-Solutions/jertel/pcap
jertel Mar 14, 2024
ca2047d
Add Version Number to External JS Filenames
coreyogburn Mar 14, 2024
12b4ebb
Merge pull request #388 from Security-Onion-Solutions/cogburn/js-ver-fix
coreyogburn Mar 14, 2024
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
11 changes: 8 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

FROM ghcr.io/security-onion-solutions/golang:1.21.5-alpine as builder
ARG VERSION=0.0.0
RUN apk update && apk add libpcap-dev bash git musl-dev gcc npm python3 py3-pip py3-virtualenv
RUN apk update && apk add libpcap-dev bash git musl-dev gcc npm python3 py3-pip py3-virtualenv python3-dev openssl-dev linux-headers
COPY . /build
WORKDIR /build
RUN if [ "$VERSION" != "0.0.0" ]; then mkdir gitdocs && cd gitdocs && \
Expand All @@ -22,6 +22,9 @@ RUN if [ "$VERSION" != "0.0.0" ]; then mkdir gitdocs && cd gitdocs && \
RUN npm install jest jest-environment-jsdom --global
RUN ./build.sh "$VERSION"

RUN pip3 install sigma-cli pysigma-backend-elasticsearch pysigma-pipeline-windows yara-python --break-system-packages
RUN sed -i 's/#!\/usr\/bin\/python3/#!\/usr\/bin\/env python/g' /usr/bin/sigma

FROM ghcr.io/security-onion-solutions/python:3-slim

ARG UID=939
Expand All @@ -30,8 +33,8 @@ ARG VERSION=0.0.0
ARG ELASTIC_VERSION=0.0.0
ARG WAZUH_VERSION=0.0.0

RUN apt update -y
RUN apt install -y bash tzdata ca-certificates wget curl tcpdump unzip tshark
RUN apt update -y
RUN apt install -y bash tzdata ca-certificates wget curl tcpdump unzip
RUN update-ca-certificates
RUN addgroup --gid "$GID" socore
RUN adduser --disabled-password --uid "$UID" --ingroup socore --gecos '' socore
Expand All @@ -46,6 +49,8 @@ COPY --from=builder /build/LICENSE .
COPY --from=builder /build/README.md .
COPY --from=builder /build/sensoroni.json .
COPY --from=builder /build/gitdocs/_build/html ./html/docs
COPY --from=builder /usr/lib/python3.11/site-packages /usr/local/lib/python3.9/site-packages
COPY --from=builder /usr/bin/sigma /usr/bin/sigma
RUN find html/js -name "*test*.js" -delete
RUN chmod u+x scripts/*
RUN chown 939:939 scripts/*
Expand Down
26 changes: 14 additions & 12 deletions Dockerfile.kratos
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@
# https://securityonion.net/license; you may not use this file except in compliance with the
# Elastic License 2.0.

FROM ghcr.io/security-onion-solutions/golang:alpine AS builder
FROM ghcr.io/security-onion-solutions/golang:1.21 AS builder

ARG OWNER=ory
ARG VERSION=v1.0.0
ARG VERSION=v1.1.0

RUN addgroup --system ory; \
adduser --system ory --no-create-home --disabled-password --ingroup ory --disabled-login

RUN apt-get update && apt-get upgrade -y && apt-get install -y git gcc bash
RUN mkdir -p /var/lib/sqlite

RUN addgroup -S ory; \
adduser -S ory -G ory -D -H -s /bin/nologin
RUN apk -U --no-cache add build-base git gcc bash

RUN mkdir -p /go/src/github.com/$OWNER
WORKDIR /go/src/github.com/$OWNER
Expand All @@ -23,23 +26,22 @@ RUN git checkout $VERSION

ENV GO111MODULE on
ENV CGO_ENABLED 1
ENV CGO_CPPFLAGS -DSQLITE_DEFAULT_FILE_PERMISSIONS=0600

RUN go mod download
RUN go build -tags sqlite -a
RUN go build -tags sqlite -ldflags="-X 'github.com/ory/kratos/driver/config.Version=${VERSION}' -X 'github.com/ory/kratos/driver/config.Date=$(date -I)' -X 'github.com/ory/kratos/driver/config.Commit=$(git rev-parse --short HEAD)'"


FROM ghcr.io/security-onion-solutions/alpine:latest
FROM ghcr.io/security-onion-solutions/ubuntu:23.04

ENV DSN=sqlite:///kratos-data/db.sqlite?_fk=true

ARG UID=928
ARG GID=928
ARG OWNER=ory

RUN addgroup --gid "$GID" -S kratos; \
adduser -u "$UID" -S kratos -G kratos -D -H -s /bin/nologin
RUN apk add -U --no-cache ca-certificates

RUN [ ! -e /etc/nsswitch.conf ] && echo 'hosts: files dns' > /etc/nsswitch.conf
RUN groupadd --system kratos --gid "$GID" ; \
useradd --system kratos --no-create-home -g kratos --uid "$UID"

RUN echo "#!/bin/sh" > /start-kratos.sh
RUN echo "kratos -c /kratos-conf/kratos.yaml migrate sql -e --yes >> /kratos-log/kratos-migrate.log 2>&1" >> /start-kratos.sh
Expand Down
12 changes: 6 additions & 6 deletions agent/jobmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,14 @@ func (mgr *JobManager) ProcessJob(job *model.Job) (io.ReadCloser, error) {
defer mgr.lock.RUnlock()
var reader io.ReadCloser
var err error

job.Size = 0
for _, processor := range mgr.jobProcessors {
reader, err = processor.ProcessJob(job, reader)
if err != nil {
log.WithError(err).WithFields(log.Fields{
"jobId": job.Id,
}).Error("Failed to process job; job processing aborted")
break
}
}
if err != nil && reader != nil {
// Don't fail all processors if at least one provided some data.
err = nil
}
return reader, err
}
Expand Down
37 changes: 33 additions & 4 deletions agent/jobmanager_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
// Copyright 2020-2023 Security Onion Solutions LLC and/or licensed to Security Onion Solutions LLC under one
// or more contributor license agreements. Licensed under the Elastic License 2.0 as shown at
// https://securityonion.net/license; you may not use this file except in compliance with the
// Elastic License 2.0.

package agent

import (
Expand Down Expand Up @@ -46,10 +51,14 @@ func (jp *idJobProcessor) GetDataEpoch() time.Time {
}

// panicProcessor is a JobProcessor that always returns an error.
type panicProcessor struct{}
type panicProcessor struct {
processCount int
errorString string
}

func (jp *panicProcessor) ProcessJob(job *model.Job, reader io.ReadCloser) (io.ReadCloser, error) {
return reader, errors.New("panic")
jp.processCount++
return reader, errors.New(jp.errorString)
}

func (jp *panicProcessor) CleanupJob(*model.Job) {}
Expand All @@ -64,7 +73,7 @@ func TestProcessJob(t *testing.T) {
jm := &JobManager{}

jm.AddJobProcessor(&idJobProcessor{})
jm.AddJobProcessor(&panicProcessor{})
jm.AddJobProcessor(&panicProcessor{errorString: "panic"})

// prep model
job := &model.Job{
Expand All @@ -79,7 +88,27 @@ func TestProcessJob(t *testing.T) {
assert.NoError(t, rerr)

assert.Equal(t, "101", string(data))
assert.ErrorContains(t, err, "panic")
assert.Nil(t, err)
}

func TestProcessJobContinuesIfNoDataAvailable(t *testing.T) {
// prep test object
jm := &JobManager{}

proc := panicProcessor{errorString: "No data available"}
jm.AddJobProcessor(&proc)
jm.AddJobProcessor(&proc)

// prep model
job := &model.Job{
Id: 101,
}

// test
_, err := jm.ProcessJob(job)

assert.Equal(t, 2, proc.processCount)
assert.ErrorContains(t, err, "No data available")
}

func TestUpdateDataEpoch(t *testing.T) {
Expand Down
25 changes: 24 additions & 1 deletion agent/modules/importer/importer.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,32 @@ func (importer *Importer) ProcessJob(job *model.Job, reader io.ReadCloser) (io.R
}).Debug("Executed tcpdump")
if err == nil {
var file *os.File
var info os.FileInfo
file, err = os.Open(pcapOutputFilepath)
if err == nil {
reader = file
info, err = os.Stat(pcapOutputFilepath)
if err != nil {
log.WithError(err).WithFields(log.Fields{
"pcapPath": pcapOutputFilepath,
}).Error("Failed to collect output file stats")
} else {
size := int(info.Size())
log.WithFields(log.Fields{
"pcapPath": pcapOutputFilepath,
"pcapSize": size,
"jobSize": job.Size,
}).Debug("Found matching packets")
if job.Size > size {
log.Warn("Discarding Importer job output since existing job already has more content from another processor")
} else {
job.Size = size
reader = file
log.WithFields(log.Fields{
"pcapStreamErr": err,
"pcapStreamSize": size,
}).Debug("Finished processing PCAP via Importer")
}
}
}
}
}
Expand Down
24 changes: 23 additions & 1 deletion agent/modules/stenoquery/stenoquery.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,31 @@ func (steno *StenoQuery) ProcessJob(job *model.Job, reader io.ReadCloser) (io.Re
}).Debug("Executed stenoread")
if err == nil {
var file *os.File
var info os.FileInfo
file, err = os.Open(pcapFilepath)
if err == nil {
reader = file
info, err = os.Stat(pcapFilepath)
if err != nil {
log.WithError(err).WithFields(log.Fields{
"pcapPath": pcapFilepath,
}).Error("Failed to collect output file stats")
} else {
size := int(info.Size())
log.WithFields(log.Fields{
"pcapPath": pcapFilepath,
"pcapBytes": size,
}).Debug("Found matching packets")
if job.Size > size {
log.Warn("Discarding Stenographer job output since existing job already has more content from another processor")
} else {
job.Size = size
reader = file
log.WithFields(log.Fields{
"pcapStreamErr": err,
"pcapStreamSize": size,
}).Debug("Finished processing PCAP via Stenographer")
}
}
}
}
}
Expand Down
Loading
Loading