mirror of
https://github.com/Security-Onion-Solutions/securityonion.git
synced 2026-12-06 10:46:08 +01:00
Compare commits
14
Commits
kilo
...
m0duspwnens/595
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
248fa193db | ||
|
|
9152e6fce0 | ||
|
|
62a7ba40f6 | ||
|
|
7ec2dec143 | ||
|
|
df44fe7670 | ||
|
|
2773b8479f | ||
|
|
da7bdd63cd | ||
|
|
5a59a83fef | ||
|
|
dfcfa580e5 | ||
|
|
99ee0d9750 | ||
|
|
80c5c38cd5 | ||
|
|
4fa5b48035 | ||
|
|
ce91c5249b | ||
|
|
4f9981ebf9 |
No files matched your search
@@ -164,6 +164,7 @@ if [[ $EXCLUDE_FALSE_POSITIVE_ERRORS == 'Y' ]]; then
|
|||||||
EXCLUDED_ERRORS="$EXCLUDED_ERRORS|syncing rule" # false positive (rule sync log line includes rule name which can contain 'error')
|
EXCLUDED_ERRORS="$EXCLUDED_ERRORS|syncing rule" # false positive (rule sync log line includes rule name which can contain 'error')
|
||||||
EXCLUDED_ERRORS="$EXCLUDED_ERRORS|request_unauthorized" # false positive (login failures to Hydra result in an 'error' log)
|
EXCLUDED_ERRORS="$EXCLUDED_ERRORS|request_unauthorized" # false positive (login failures to Hydra result in an 'error' log)
|
||||||
EXCLUDED_ERRORS="$EXCLUDED_ERRORS|adding index lifecycle policy" # false positive (elasticsearch policy names contain 'error')
|
EXCLUDED_ERRORS="$EXCLUDED_ERRORS|adding index lifecycle policy" # false positive (elasticsearch policy names contain 'error')
|
||||||
|
EXCLUDED_ERRORS="$EXCLUDED_ERRORS|updating index lifecycle policy" # false positive (elasticsearch policy names contain 'error')
|
||||||
EXCLUDED_ERRORS="$EXCLUDED_ERRORS|adding ingest pipeline" # false positive (elasticsearch ingest pipeline names contain 'error')
|
EXCLUDED_ERRORS="$EXCLUDED_ERRORS|adding ingest pipeline" # false positive (elasticsearch ingest pipeline names contain 'error')
|
||||||
EXCLUDED_ERRORS="$EXCLUDED_ERRORS|updating index template" # false positive (elasticsearch index or template names contain 'error')
|
EXCLUDED_ERRORS="$EXCLUDED_ERRORS|updating index template" # false positive (elasticsearch index or template names contain 'error')
|
||||||
EXCLUDED_ERRORS="$EXCLUDED_ERRORS|updating component template" # false positive (elasticsearch index or template names contain 'error')
|
EXCLUDED_ERRORS="$EXCLUDED_ERRORS|updating component template" # false positive (elasticsearch index or template names contain 'error')
|
||||||
@@ -179,6 +180,7 @@ if [[ $EXCLUDE_FALSE_POSITIVE_ERRORS == 'Y' ]]; then
|
|||||||
EXCLUDED_ERRORS="$EXCLUDED_ERRORS|Static assets preprocessor only supports GET and HEAD requests" # expected WARN log lines indicating invalid auth header
|
EXCLUDED_ERRORS="$EXCLUDED_ERRORS|Static assets preprocessor only supports GET and HEAD requests" # expected WARN log lines indicating invalid auth header
|
||||||
EXCLUDED_ERRORS="$EXCLUDED_ERRORS|respondError" # respondError is a function name, output via http middleware as standard request logging
|
EXCLUDED_ERRORS="$EXCLUDED_ERRORS|respondError" # respondError is a function name, output via http middleware as standard request logging
|
||||||
EXCLUDED_ERRORS="$EXCLUDED_ERRORS|GET /kibana/" # Ignore Kibana queries with triggered words
|
EXCLUDED_ERRORS="$EXCLUDED_ERRORS|GET /kibana/" # Ignore Kibana queries with triggered words
|
||||||
|
EXCLUDED_ERRORS="$EXCLUDED_ERRORS|error-logs" # Elastic indexes can contain error-logs in their names, which can trigger false positives in log checks
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $EXCLUDE_KNOWN_ERRORS == 'Y' ]]; then
|
if [[ $EXCLUDE_KNOWN_ERRORS == 'Y' ]]; then
|
||||||
|
|||||||
@@ -17,7 +17,10 @@ elasticsearch:
|
|||||||
global: True
|
global: True
|
||||||
advanced: True
|
advanced: True
|
||||||
esheap:
|
esheap:
|
||||||
description: Specify the memory heap size in (m)egabytes for Elasticsearch.
|
description: Heap size to use for Elasticsearch, as a number followed by k (kilobytes), m (megabytes) or g (gigabytes), such as 600m.
|
||||||
|
forcedType: string
|
||||||
|
regex: ^[1-9][0-9]*[kKmMgG]$
|
||||||
|
regexFailureMessage: Must be a whole number followed by k, m or g, such as 600m.
|
||||||
helpLink: elasticsearch
|
helpLink: elasticsearch
|
||||||
index_clean:
|
index_clean:
|
||||||
description: Determines if indices should be considered for deletion by available disk space in the cluster. Otherwise, data is retained by the configured lifecycle settings. This setting only applies to EVAL, STANDALONE, and HEAVY NODE installations. Other installations use lifecycle settings only.
|
description: Determines if indices should be considered for deletion by available disk space in the cluster. Otherwise, data is retained by the configured lifecycle settings. This setting only applies to EVAL, STANDALONE, and HEAVY NODE installations. Other installations use lifecycle settings only.
|
||||||
|
|||||||
@@ -403,8 +403,11 @@ logstash:
|
|||||||
custom8: *pipeline_settings
|
custom8: *pipeline_settings
|
||||||
custom9: *pipeline_settings
|
custom9: *pipeline_settings
|
||||||
settings:
|
settings:
|
||||||
lsheap:
|
lsheap:
|
||||||
description: Heap size to use for logstash
|
description: Heap size to use for Logstash, as a number followed by k (kilobytes), m (megabytes) or g (gigabytes), such as 500m.
|
||||||
|
forcedType: string
|
||||||
|
regex: ^[1-9][0-9]*[kKmMgG]$
|
||||||
|
regexFailureMessage: Must be a whole number followed by k, m or g, such as 500m.
|
||||||
helpLink: logstash
|
helpLink: logstash
|
||||||
global: False
|
global: False
|
||||||
config:
|
config:
|
||||||
|
|||||||
@@ -20,11 +20,17 @@ CRITICAL_AGENTS_FILE="/opt/so/conf/agents/critical-agents.txt"
|
|||||||
OFFLINE_THRESHOLD_HOURS={{ OFFLINE_THRESHOLD_HOURS }}
|
OFFLINE_THRESHOLD_HOURS={{ OFFLINE_THRESHOLD_HOURS }}
|
||||||
REALERT_THRESHOLD={{ REALERT_THRESHOLD }}
|
REALERT_THRESHOLD={{ REALERT_THRESHOLD }}
|
||||||
PAGE_SIZE="{{ PAGE_SIZE }}"
|
PAGE_SIZE="{{ PAGE_SIZE }}"
|
||||||
|
# Safety limit on pagination loops; Fleet page-based results are also capped at 10000 agents.
|
||||||
|
MAX_PAGES=100
|
||||||
|
|
||||||
log_message() {
|
log_message() {
|
||||||
local level="$1"
|
local level="$1"
|
||||||
local message="$2"
|
local message="$2"
|
||||||
echo "$(date -u +"%Y-%m-%dT%H:%M:%SZ") [$level] $message" >&2
|
echo "$(date -u +"%Y-%m-%dT%H:%M:%SZ") [$level] $message" >&2
|
||||||
|
# ERROR also goes to syslog: cron output is not monitored, and syslog is shipped to Elasticsearch.
|
||||||
|
if [ "$level" = "ERROR" ]; then
|
||||||
|
logger -t so-elastic-agent-monitor -p user.err -- "ERROR: $message" 2>/dev/null || true
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
matches_critical_pattern() {
|
matches_critical_pattern() {
|
||||||
@@ -135,42 +141,70 @@ main() {
|
|||||||
local page=1
|
local page=1
|
||||||
local total_agents=0
|
local total_agents=0
|
||||||
local processed_agents=0
|
local processed_agents=0
|
||||||
|
local agents_in_page=0
|
||||||
|
local agents=()
|
||||||
local current_timestamp=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
|
local current_timestamp=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
|
||||||
|
|
||||||
{%- if CUSTOM_KQUERY != None and CUSTOM_KQUERY | length > 0 %}
|
{%- if CUSTOM_KQUERY != None and CUSTOM_KQUERY | length > 0 %}
|
||||||
log_message "INFO" "Using custom kquery: {{ CUSTOM_KQUERY }}"
|
log_message "INFO" "Using custom kquery: {{ CUSTOM_KQUERY }}"
|
||||||
FLEET_QUERY="${FLEET_API}?kuery={{ CUSTOM_KQUERY | urlencode }}&perPage=${PAGE_SIZE}&page=${page}"
|
FLEET_QUERY="${FLEET_API}?kuery={{ CUSTOM_KQUERY | urlencode }}&perPage=${PAGE_SIZE}"
|
||||||
{%- else %}
|
{%- else %}
|
||||||
log_message "INFO" "Using default query (all offline or degraded agents)"
|
log_message "INFO" "Using default query (all offline or degraded agents)"
|
||||||
FLEET_QUERY="${FLEET_API}?kuery=status%3Aoffline%20OR%20status%3Adegraded&perPage=${PAGE_SIZE}&page=${page}"
|
FLEET_QUERY="${FLEET_API}?kuery=status%3Aoffline%20OR%20status%3Adegraded&perPage=${PAGE_SIZE}"
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
|
if (( page * PAGE_SIZE > 10000 )); then
|
||||||
|
log_message "ERROR" "Fleet page-based results are limited to 10000 agents (page $page x page_size $PAGE_SIZE); $processed_agents of $total_agents agents were checked. Narrow the agents being monitored with custom_kquery under Administration -> Configuration -> manager -> agent_monitoring -> config (enable 'Show advanced settings')."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
log_message "INFO" "Fetching page $page (${PAGE_SIZE} agents per page)"
|
log_message "INFO" "Fetching page $page (${PAGE_SIZE} agents per page)"
|
||||||
|
|
||||||
if ! response_body=$(curl -K "$CURL_CONFIG" \
|
if ! response_body=$(curl -K "$CURL_CONFIG" \
|
||||||
-s --fail \
|
-s --fail \
|
||||||
"$FLEET_QUERY" \
|
"${FLEET_QUERY}&page=${page}" \
|
||||||
-H 'kbn-xsrf: true' 2>/dev/null); then
|
-H 'kbn-xsrf: true' 2>/dev/null); then
|
||||||
log_message "ERROR" "Failed to query Fleet API (page $page)"
|
log_message "ERROR" "Failed to query Fleet API (page $page)"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# pagination info
|
# Validate the response before parsing it so a bad response can never be
|
||||||
current_total=$(echo "$response_body" | jq -r '.total // 0')
|
# mistaken for an empty page.
|
||||||
current_page=$(echo "$response_body" | jq -r '.page // 1')
|
if ! echo "$response_body" | jq -e 'type == "object"' >/dev/null 2>&1; then
|
||||||
agents_in_page=$(echo "$response_body" | jq -r '.list | length')
|
log_message "ERROR" "Malformed Fleet API response on page $page: not a valid JSON object"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Update total
|
if ! current_total=$(echo "$response_body" | jq -e '.total | select(type == "number" and . >= 0 and . == floor)' 2>/dev/null); then
|
||||||
|
log_message "ERROR" "Malformed Fleet API response on page $page: missing or invalid total"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Fleet 9.x returns agents under "items"; older responses used "list".
|
||||||
|
if ! agents_json=$(echo "$response_body" | jq -c '(.items // .list) | if type == "array" then .[] else error("no agent array") end' 2>/dev/null); then
|
||||||
|
log_message "ERROR" "Malformed Fleet API response on page $page: missing or invalid agent collection (items/list)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Use the latest page's total: agents changing status between pages
|
||||||
|
# (e.g. coming back online) shrink the offline/degraded result set.
|
||||||
|
total_agents="$current_total"
|
||||||
if [ "$page" -eq 1 ]; then
|
if [ "$page" -eq 1 ]; then
|
||||||
total_agents="$current_total"
|
|
||||||
log_message "INFO" "Found $total_agents total agents across all pages"
|
log_message "INFO" "Found $total_agents total agents across all pages"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
log_message "INFO" "Processing page $current_page with $agents_in_page agents"
|
|
||||||
|
|
||||||
# Process agents from current page
|
# Process agents from current page
|
||||||
mapfile -t agents < <(echo "$response_body" | jq -c '.list[]')
|
agents=()
|
||||||
|
agents_in_page=0
|
||||||
|
if [ -n "$agents_json" ]; then
|
||||||
|
while IFS= read -r agent; do
|
||||||
|
agents+=("$agent")
|
||||||
|
agents_in_page=$((agents_in_page + 1))
|
||||||
|
done <<< "$agents_json"
|
||||||
|
fi
|
||||||
|
|
||||||
|
log_message "INFO" "Processing page $page with $agents_in_page agents"
|
||||||
|
|
||||||
for agent in "${agents[@]}"; do
|
for agent in "${agents[@]}"; do
|
||||||
# Grab agent details
|
# Grab agent details
|
||||||
@@ -234,17 +268,20 @@ main() {
|
|||||||
|
|
||||||
processed_agents=$((processed_agents + agents_in_page))
|
processed_agents=$((processed_agents + agents_in_page))
|
||||||
|
|
||||||
if [ "$agents_in_page" -eq 0 ] || [ "$processed_agents" -ge "$total_agents" ]; then
|
if [ "$processed_agents" -ge "$total_agents" ]; then
|
||||||
log_message "INFO" "Completed processing all pages. Total processed: $processed_agents agents"
|
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "$agents_in_page" -eq 0 ]; then
|
||||||
|
log_message "ERROR" "Incomplete agent scan: page $page was empty after $processed_agents of $total_agents agents"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
page=$((page + 1))
|
page=$((page + 1))
|
||||||
|
|
||||||
# Limit pagination loops incase of any issues. If agent count is high enough increase page_size in SOC manager.agent_monitoring.config.page_size
|
if [ "$page" -gt "$MAX_PAGES" ]; then
|
||||||
if [ "$page" -gt 100 ]; then
|
log_message "ERROR" "Reached maximum page limit ($MAX_PAGES) after $processed_agents of $total_agents agents. Issue with script or extremely large fleet deployment. Consider increasing page_size under Administration -> Configuration -> manager -> agent_monitoring -> config -> page_size (enable 'Show advanced settings')."
|
||||||
log_message "ERROR" "Reached maximum page limit (100). Issue with script or extremely large fleet deployment. Consider increasing page_size in SOC -> manager.agent_monitoring.config.page_size"
|
exit 1
|
||||||
break
|
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|||||||
@@ -2557,6 +2557,61 @@ soc:
|
|||||||
grid:
|
grid:
|
||||||
maxUploadSize: 26214400
|
maxUploadSize: 26214400
|
||||||
staleMetricsMs: 120000
|
staleMetricsMs: 120000
|
||||||
|
recommendedAlarms:
|
||||||
|
- name: Root Disk Usage
|
||||||
|
metric: disk
|
||||||
|
metricKey: disk_used_root
|
||||||
|
operator: gt
|
||||||
|
threshold: '95'
|
||||||
|
durationSeconds: 300
|
||||||
|
severity: critical
|
||||||
|
clearedSeverity: info
|
||||||
|
enabled: true
|
||||||
|
- name: NSM Disk Usage
|
||||||
|
metric: disk
|
||||||
|
metricKey: disk_used_nsm
|
||||||
|
operator: gt
|
||||||
|
threshold: '95'
|
||||||
|
durationSeconds: 300
|
||||||
|
severity: critical
|
||||||
|
clearedSeverity: info
|
||||||
|
enabled: true
|
||||||
|
- name: Low PCAP Retention
|
||||||
|
metric: pcap_retention
|
||||||
|
metricKey: pcap_retention
|
||||||
|
operator: lt
|
||||||
|
threshold: '1'
|
||||||
|
durationSeconds: 300
|
||||||
|
severity: critical
|
||||||
|
clearedSeverity: info
|
||||||
|
enabled: true
|
||||||
|
- name: Suricata Packet Loss
|
||||||
|
metric: loss
|
||||||
|
metricKey: suricata_loss
|
||||||
|
operator: gt
|
||||||
|
threshold: '5'
|
||||||
|
durationSeconds: 300
|
||||||
|
severity: critical
|
||||||
|
clearedSeverity: info
|
||||||
|
enabled: true
|
||||||
|
- name: Zeek Packet Loss
|
||||||
|
metric: loss
|
||||||
|
metricKey: zeek_loss
|
||||||
|
operator: gt
|
||||||
|
threshold: '5'
|
||||||
|
durationSeconds: 300
|
||||||
|
severity: critical
|
||||||
|
clearedSeverity: info
|
||||||
|
enabled: true
|
||||||
|
- name: Low Monitor Traffic
|
||||||
|
metric: net
|
||||||
|
metricKey: traffic_mon_in
|
||||||
|
operator: lt
|
||||||
|
threshold: '5'
|
||||||
|
durationSeconds: 300
|
||||||
|
severity: critical
|
||||||
|
clearedSeverity: info
|
||||||
|
enabled: true
|
||||||
cases:
|
cases:
|
||||||
advanced: false
|
advanced: false
|
||||||
aggregationActionsEnabled: false
|
aggregationActionsEnabled: false
|
||||||
|
|||||||
@@ -1343,6 +1343,69 @@ soc:
|
|||||||
staleMetricsMs:
|
staleMetricsMs:
|
||||||
description: The age in milliseconds of node metrics when they are considered stale. Stale metrics have a faded appearance on the Grid screen.
|
description: The age in milliseconds of node metrics when they are considered stale. Stale metrics have a faded appearance on the Grid screen.
|
||||||
global: True
|
global: True
|
||||||
|
recommendedAlarms:
|
||||||
|
description: Recommended alarms offered on the Grid page's Alarms tab and Options dialog.
|
||||||
|
global: True
|
||||||
|
advanced: True
|
||||||
|
forcedType: "[]{}"
|
||||||
|
syntax: json
|
||||||
|
helpLink: grid
|
||||||
|
uiElements:
|
||||||
|
- field: name
|
||||||
|
label: Name
|
||||||
|
required: True
|
||||||
|
- field: metric
|
||||||
|
label: Metric
|
||||||
|
required: True
|
||||||
|
- field: metricKey
|
||||||
|
label: Metric Key
|
||||||
|
required: False
|
||||||
|
- field: operator
|
||||||
|
label: Operator
|
||||||
|
required: True
|
||||||
|
options:
|
||||||
|
- gt
|
||||||
|
- gte
|
||||||
|
- lt
|
||||||
|
- lte
|
||||||
|
- eq
|
||||||
|
- ne
|
||||||
|
- contains
|
||||||
|
- field: threshold
|
||||||
|
label: Threshold
|
||||||
|
required: True
|
||||||
|
forcedType: string
|
||||||
|
- field: durationSeconds
|
||||||
|
label: Duration Seconds
|
||||||
|
required: False
|
||||||
|
forcedType: int
|
||||||
|
- field: severity
|
||||||
|
label: Severity
|
||||||
|
required: True
|
||||||
|
options:
|
||||||
|
- critical
|
||||||
|
- high
|
||||||
|
- medium
|
||||||
|
- low
|
||||||
|
- info
|
||||||
|
- field: clearedSeverity
|
||||||
|
label: Cleared Severity
|
||||||
|
required: False
|
||||||
|
options:
|
||||||
|
- none
|
||||||
|
- critical
|
||||||
|
- high
|
||||||
|
- medium
|
||||||
|
- low
|
||||||
|
- info
|
||||||
|
- field: enabled
|
||||||
|
label: Enabled
|
||||||
|
required: False
|
||||||
|
forcedType: bool
|
||||||
|
- field: note
|
||||||
|
label: Note
|
||||||
|
required: False
|
||||||
|
multiline: True
|
||||||
case:
|
case:
|
||||||
analyzerNodeId:
|
analyzerNodeId:
|
||||||
description: The node ID on which analyzers will be executed.
|
description: The node ID on which analyzers will be executed.
|
||||||
|
|||||||
Reference in new issue
Block a user