mirror of
https://github.com/crowdsecurity/crowdsec.git
synced 2025-05-10 20:05:55 +02:00
Merge branch 'master' into releases/1.6.x
Some checks are pending
Tests / sqlite (push) Waiting to run
Tests / mariadb (push) Waiting to run
Tests / mysql (push) Waiting to run
Tests / postgres (push) Waiting to run
Tests / hub (push) Waiting to run
Release Drafter / update_release_draft (push) Waiting to run
CodeQL / Analyze (push) Waiting to run
Test Docker images / test_flavor (debian) (push) Waiting to run
Test Docker images / test_flavor (slim) (push) Waiting to run
Go tests (windows) / Build + tests (push) Waiting to run
Build / Build + tests (push) Waiting to run
Some checks are pending
Tests / sqlite (push) Waiting to run
Tests / mariadb (push) Waiting to run
Tests / mysql (push) Waiting to run
Tests / postgres (push) Waiting to run
Tests / hub (push) Waiting to run
Release Drafter / update_release_draft (push) Waiting to run
CodeQL / Analyze (push) Waiting to run
Test Docker images / test_flavor (debian) (push) Waiting to run
Test Docker images / test_flavor (slim) (push) Waiting to run
Go tests (windows) / Build + tests (push) Waiting to run
Build / Build + tests (push) Waiting to run
This commit is contained in:
commit
bc2744986e
14 changed files with 219 additions and 178 deletions
302
.github/codecov.yml
vendored
302
.github/codecov.yml
vendored
|
@ -15,150 +15,172 @@ coverage:
|
|||
# if a directory is ignored, there is no way to un-ignore files like pkg/models/helpers.go
|
||||
# so we make a full list
|
||||
ignore:
|
||||
- "./pkg/modelscapi/success_response.go"
|
||||
- "./pkg/modelscapi/get_decisions_stream_response_deleted.go"
|
||||
- "./pkg/modelscapi/login_request.go"
|
||||
- "./pkg/modelscapi/get_decisions_stream_response_links.go"
|
||||
- "./pkg/modelscapi/login_response.go"
|
||||
- "./pkg/modelscapi/add_signals_request_item.go"
|
||||
- "./pkg/modelscapi/blocklist_link.go"
|
||||
- "./pkg/modelscapi/get_decisions_stream_response_deleted_item.go"
|
||||
- "./pkg/modelscapi/decisions_sync_request.go"
|
||||
- "./pkg/modelscapi/get_decisions_stream_response.go"
|
||||
- "./pkg/modelscapi/metrics_request_machines_item.go"
|
||||
- "./pkg/modelscapi/metrics_request.go"
|
||||
- "./pkg/modelscapi/get_decisions_stream_response_new.go"
|
||||
- "./pkg/modelscapi/add_signals_request_item_decisions_item.go"
|
||||
- "./pkg/modelscapi/metrics_request_bouncers_item.go"
|
||||
- "./pkg/modelscapi/decisions_sync_request_item_decisions_item.go"
|
||||
- "./pkg/modelscapi/decisions_delete_request_item.go"
|
||||
- "./pkg/modelscapi/get_decisions_stream_response_new_item.go"
|
||||
- "./pkg/modelscapi/decisions_sync_request_item.go"
|
||||
- "./pkg/modelscapi/add_signals_request.go"
|
||||
- "./pkg/modelscapi/reset_password_request.go"
|
||||
- "./pkg/modelscapi/add_signals_request_item_decisions.go"
|
||||
- "./pkg/modelscapi/decisions_sync_request_item_source.go"
|
||||
- "./pkg/modelscapi/error_response.go"
|
||||
- "./pkg/modelscapi/decisions_delete_request.go"
|
||||
- "./pkg/modelscapi/decisions_sync_request_item_decisions.go"
|
||||
- "./pkg/modelscapi/enroll_request.go"
|
||||
- "./pkg/modelscapi/register_request.go"
|
||||
- "./pkg/modelscapi/add_signals_request_item_source.go"
|
||||
- "./pkg/models/success_response.go"
|
||||
- "./pkg/models/hub_items.go"
|
||||
- "./pkg/models/alert.go"
|
||||
- "./pkg/models/metrics_bouncer_info.go"
|
||||
- "./pkg/models/add_signals_request_item.go"
|
||||
- "./pkg/models/metrics_meta.go"
|
||||
- "./pkg/models/metrics_detail_item.go"
|
||||
- "./pkg/models/add_signals_request_item_decisions_item.go"
|
||||
- "./pkg/models/hub_item.go"
|
||||
- "./pkg/models/get_alerts_response.go"
|
||||
- "./pkg/models/metrics_labels.go"
|
||||
- "./pkg/models/watcher_auth_request.go"
|
||||
- "./pkg/models/add_alerts_request.go"
|
||||
- "./pkg/models/event.go"
|
||||
- "./pkg/models/decisions_delete_request_item.go"
|
||||
- "./pkg/models/meta.go"
|
||||
- "./pkg/models/detailed_metrics.go"
|
||||
- "./pkg/models/delete_alerts_response.go"
|
||||
- "./pkg/models/remediation_components_metrics.go"
|
||||
- "./pkg/models/console_options.go"
|
||||
- "./pkg/models/topx_response.go"
|
||||
- "./pkg/models/add_signals_request.go"
|
||||
- "./pkg/models/delete_decision_response.go"
|
||||
- "./pkg/models/get_decisions_response.go"
|
||||
- "./pkg/models/add_signals_request_item_decisions.go"
|
||||
- "./pkg/models/source.go"
|
||||
- "./pkg/models/decisions_stream_response.go"
|
||||
- "./pkg/models/error_response.go"
|
||||
- "./pkg/models/all_metrics.go"
|
||||
- "./pkg/models/o_sversion.go"
|
||||
- "./pkg/models/decision.go"
|
||||
- "./pkg/models/decisions_delete_request.go"
|
||||
- "./pkg/models/flush_decision_response.go"
|
||||
- "./pkg/models/watcher_auth_response.go"
|
||||
- "./pkg/models/lapi_metrics.go"
|
||||
- "./pkg/models/watcher_registration_request.go"
|
||||
- "./pkg/models/metrics_agent_info.go"
|
||||
- "./pkg/models/log_processors_metrics.go"
|
||||
- "./pkg/models/add_signals_request_item_source.go"
|
||||
- "./pkg/models/base_metrics.go"
|
||||
- "./pkg/models/add_alerts_response.go"
|
||||
- "./pkg/models/metrics.go"
|
||||
- "./pkg/protobufs/notifier.pb.go"
|
||||
- "./pkg/protobufs/notifier_grpc.pb.go"
|
||||
- "./pkg/database/ent/metric_update.go"
|
||||
- "./pkg/database/ent/machine_delete.go"
|
||||
- "./pkg/database/ent/decision_query.go"
|
||||
- "./pkg/database/ent/meta_query.go"
|
||||
- "./pkg/database/ent/metric/where.go"
|
||||
- "./pkg/database/ent/metric/metric.go"
|
||||
- "./pkg/database/ent/machine_create.go"
|
||||
- "./pkg/database/ent/alert.go"
|
||||
- "./pkg/database/ent/event_update.go"
|
||||
- "./pkg/database/ent/alert_create.go"
|
||||
- "./pkg/database/ent/alert_query.go"
|
||||
- "./pkg/database/ent/metric_delete.go"
|
||||
- "./pkg/database/ent/lock_create.go"
|
||||
- "./pkg/database/ent/bouncer_update.go"
|
||||
- "./pkg/database/ent/meta_update.go"
|
||||
- "./pkg/database/ent/decision_create.go"
|
||||
- "./pkg/database/ent/configitem_update.go"
|
||||
- "./pkg/database/ent/machine_query.go"
|
||||
- "./pkg/database/ent/client.go"
|
||||
- "./pkg/database/ent/predicate/predicate.go"
|
||||
- "./pkg/database/ent/lock/where.go"
|
||||
- "./pkg/database/ent/lock/lock.go"
|
||||
- "./pkg/database/ent/mutation.go"
|
||||
- "./pkg/database/ent/migrate/migrate.go"
|
||||
- "./pkg/database/ent/migrate/schema.go"
|
||||
- "./pkg/database/ent/configitem.go"
|
||||
- "./pkg/database/ent/metric_query.go"
|
||||
- "./pkg/database/ent/event.go"
|
||||
- "./pkg/database/ent/event_query.go"
|
||||
- "./pkg/database/ent/lock_update.go"
|
||||
- "./pkg/database/ent/meta.go"
|
||||
- "./pkg/database/ent/configitem_query.go"
|
||||
- "./pkg/database/ent/bouncer.go"
|
||||
- "./pkg/database/ent/alert_update.go"
|
||||
- "./pkg/database/ent/meta/meta.go"
|
||||
- "./pkg/database/ent/meta/where.go"
|
||||
- "./pkg/database/ent/decision_update.go"
|
||||
- "./pkg/database/ent/alert_delete.go"
|
||||
- "./pkg/database/ent/lock.go"
|
||||
- "./pkg/database/ent/runtime/runtime.go"
|
||||
- "./pkg/database/ent/alert/alert.go"
|
||||
- "./pkg/database/ent/alert_create.go"
|
||||
- "./pkg/database/ent/alert_delete.go"
|
||||
- "./pkg/database/ent/alert.go"
|
||||
- "./pkg/database/ent/alert_query.go"
|
||||
- "./pkg/database/ent/alert_update.go"
|
||||
- "./pkg/database/ent/alert/where.go"
|
||||
- "./pkg/database/ent/runtime.go"
|
||||
- "./pkg/database/ent/allowlist/allowlist.go"
|
||||
- "./pkg/database/ent/allowlist_create.go"
|
||||
- "./pkg/database/ent/allowlist_delete.go"
|
||||
- "./pkg/database/ent/allowlist.go"
|
||||
- "./pkg/database/ent/allowlistitem/allowlistitem.go"
|
||||
- "./pkg/database/ent/allowlistitem_create.go"
|
||||
- "./pkg/database/ent/allowlistitem_delete.go"
|
||||
- "./pkg/database/ent/allowlistitem.go"
|
||||
- "./pkg/database/ent/allowlistitem_query.go"
|
||||
- "./pkg/database/ent/allowlistitem_update.go"
|
||||
- "./pkg/database/ent/allowlistitem/where.go"
|
||||
- "./pkg/database/ent/allowlist_query.go"
|
||||
- "./pkg/database/ent/allowlist_update.go"
|
||||
- "./pkg/database/ent/allowlist/where.go"
|
||||
- "./pkg/database/ent/bouncer/bouncer.go"
|
||||
- "./pkg/database/ent/bouncer_create.go"
|
||||
- "./pkg/database/ent/bouncer_delete.go"
|
||||
- "./pkg/database/ent/bouncer.go"
|
||||
- "./pkg/database/ent/bouncer_query.go"
|
||||
- "./pkg/database/ent/bouncer_update.go"
|
||||
- "./pkg/database/ent/bouncer/where.go"
|
||||
- "./pkg/database/ent/hook/hook.go"
|
||||
- "./pkg/database/ent/metric.go"
|
||||
- "./pkg/database/ent/client.go"
|
||||
- "./pkg/database/ent/configitem/configitem.go"
|
||||
- "./pkg/database/ent/configitem_create.go"
|
||||
- "./pkg/database/ent/configitem_delete.go"
|
||||
- "./pkg/database/ent/tx.go"
|
||||
- "./pkg/database/ent/decision.go"
|
||||
- "./pkg/database/ent/lock_delete.go"
|
||||
- "./pkg/database/ent/decision_delete.go"
|
||||
- "./pkg/database/ent/machine/where.go"
|
||||
- "./pkg/database/ent/machine/machine.go"
|
||||
- "./pkg/database/ent/event_create.go"
|
||||
- "./pkg/database/ent/metric_create.go"
|
||||
- "./pkg/database/ent/decision/where.go"
|
||||
- "./pkg/database/ent/decision/decision.go"
|
||||
- "./pkg/database/ent/enttest/enttest.go"
|
||||
- "./pkg/database/ent/lock_query.go"
|
||||
- "./pkg/database/ent/bouncer_create.go"
|
||||
- "./pkg/database/ent/event_delete.go"
|
||||
- "./pkg/database/ent/bouncer_delete.go"
|
||||
- "./pkg/database/ent/event/event.go"
|
||||
- "./pkg/database/ent/event/where.go"
|
||||
- "./pkg/database/ent/machine.go"
|
||||
- "./pkg/database/ent/ent.go"
|
||||
- "./pkg/database/ent/meta_create.go"
|
||||
- "./pkg/database/ent/bouncer_query.go"
|
||||
- "./pkg/database/ent/meta_delete.go"
|
||||
- "./pkg/database/ent/machine_update.go"
|
||||
- "./pkg/database/ent/configitem/configitem.go"
|
||||
- "./pkg/database/ent/configitem.go"
|
||||
- "./pkg/database/ent/configitem_query.go"
|
||||
- "./pkg/database/ent/configitem_update.go"
|
||||
- "./pkg/database/ent/configitem/where.go"
|
||||
- "./pkg/database/ent/decision_create.go"
|
||||
- "./pkg/database/ent/decision/decision.go"
|
||||
- "./pkg/database/ent/decision_delete.go"
|
||||
- "./pkg/database/ent/decision.go"
|
||||
- "./pkg/database/ent/decision_query.go"
|
||||
- "./pkg/database/ent/decision_update.go"
|
||||
- "./pkg/database/ent/decision/where.go"
|
||||
- "./pkg/database/ent/ent.go"
|
||||
- "./pkg/database/ent/enttest/enttest.go"
|
||||
- "./pkg/database/ent/event_create.go"
|
||||
- "./pkg/database/ent/event_delete.go"
|
||||
- "./pkg/database/ent/event/event.go"
|
||||
- "./pkg/database/ent/event.go"
|
||||
- "./pkg/database/ent/event_query.go"
|
||||
- "./pkg/database/ent/event_update.go"
|
||||
- "./pkg/database/ent/event/where.go"
|
||||
- "./pkg/database/ent/hook/hook.go"
|
||||
- "./pkg/database/ent/lock_create.go"
|
||||
- "./pkg/database/ent/lock_delete.go"
|
||||
- "./pkg/database/ent/lock.go"
|
||||
- "./pkg/database/ent/lock/lock.go"
|
||||
- "./pkg/database/ent/lock_query.go"
|
||||
- "./pkg/database/ent/lock_update.go"
|
||||
- "./pkg/database/ent/lock/where.go"
|
||||
- "./pkg/database/ent/machine_create.go"
|
||||
- "./pkg/database/ent/machine_delete.go"
|
||||
- "./pkg/database/ent/machine.go"
|
||||
- "./pkg/database/ent/machine/machine.go"
|
||||
- "./pkg/database/ent/machine_query.go"
|
||||
- "./pkg/database/ent/machine_update.go"
|
||||
- "./pkg/database/ent/machine/where.go"
|
||||
- "./pkg/database/ent/meta_create.go"
|
||||
- "./pkg/database/ent/meta_delete.go"
|
||||
- "./pkg/database/ent/meta.go"
|
||||
- "./pkg/database/ent/meta/meta.go"
|
||||
- "./pkg/database/ent/meta_query.go"
|
||||
- "./pkg/database/ent/meta_update.go"
|
||||
- "./pkg/database/ent/meta/where.go"
|
||||
- "./pkg/database/ent/metric_create.go"
|
||||
- "./pkg/database/ent/metric_delete.go"
|
||||
- "./pkg/database/ent/metric.go"
|
||||
- "./pkg/database/ent/metric/metric.go"
|
||||
- "./pkg/database/ent/metric_query.go"
|
||||
- "./pkg/database/ent/metric_update.go"
|
||||
- "./pkg/database/ent/metric/where.go"
|
||||
- "./pkg/database/ent/migrate/migrate.go"
|
||||
- "./pkg/database/ent/migrate/schema.go"
|
||||
- "./pkg/database/ent/mutation.go"
|
||||
- "./pkg/database/ent/predicate/predicate.go"
|
||||
- "./pkg/database/ent/runtime.go"
|
||||
- "./pkg/database/ent/runtime/runtime.go"
|
||||
- "./pkg/database/ent/tx.go"
|
||||
- "./pkg/models/add_alerts_request.go"
|
||||
- "./pkg/models/add_alerts_response.go"
|
||||
- "./pkg/models/add_signals_request.go"
|
||||
- "./pkg/models/add_signals_request_item_decisions.go"
|
||||
- "./pkg/models/add_signals_request_item_decisions_item.go"
|
||||
- "./pkg/models/add_signals_request_item.go"
|
||||
- "./pkg/models/add_signals_request_item_source.go"
|
||||
- "./pkg/models/alert.go"
|
||||
- "./pkg/models/all_metrics.go"
|
||||
- "./pkg/models/allowlist_item.go"
|
||||
- "./pkg/models/base_metrics.go"
|
||||
- "./pkg/models/bulk_check_allowlist_request.go"
|
||||
- "./pkg/models/bulk_check_allowlist_response.go"
|
||||
- "./pkg/models/bulk_check_allowlist_result.go"
|
||||
- "./pkg/modelscapi/add_signals_request.go"
|
||||
- "./pkg/modelscapi/add_signals_request_item_decisions.go"
|
||||
- "./pkg/modelscapi/add_signals_request_item_decisions_item.go"
|
||||
- "./pkg/modelscapi/add_signals_request_item.go"
|
||||
- "./pkg/modelscapi/add_signals_request_item_source.go"
|
||||
- "./pkg/modelscapi/allowlist_link.go"
|
||||
- "./pkg/modelscapi/blocklist_link.go"
|
||||
- "./pkg/modelscapi/decisions_delete_request.go"
|
||||
- "./pkg/modelscapi/decisions_delete_request_item.go"
|
||||
- "./pkg/modelscapi/decisions_sync_request.go"
|
||||
- "./pkg/modelscapi/decisions_sync_request_item_decisions.go"
|
||||
- "./pkg/modelscapi/decisions_sync_request_item_decisions_item.go"
|
||||
- "./pkg/modelscapi/decisions_sync_request_item.go"
|
||||
- "./pkg/modelscapi/decisions_sync_request_item_source.go"
|
||||
- "./pkg/modelscapi/enroll_request.go"
|
||||
- "./pkg/modelscapi/error_response.go"
|
||||
- "./pkg/modelscapi/get_decisions_stream_response_deleted.go"
|
||||
- "./pkg/modelscapi/get_decisions_stream_response_deleted_item.go"
|
||||
- "./pkg/modelscapi/get_decisions_stream_response.go"
|
||||
- "./pkg/modelscapi/get_decisions_stream_response_links.go"
|
||||
- "./pkg/modelscapi/get_decisions_stream_response_new.go"
|
||||
- "./pkg/modelscapi/get_decisions_stream_response_new_item.go"
|
||||
- "./pkg/modelscapi/login_request.go"
|
||||
- "./pkg/modelscapi/login_response.go"
|
||||
- "./pkg/modelscapi/metrics_request_bouncers_item.go"
|
||||
- "./pkg/modelscapi/metrics_request.go"
|
||||
- "./pkg/modelscapi/metrics_request_machines_item.go"
|
||||
- "./pkg/modelscapi/register_request.go"
|
||||
- "./pkg/modelscapi/reset_password_request.go"
|
||||
- "./pkg/modelscapi/success_response.go"
|
||||
- "./pkg/models/check_allowlist_response.go"
|
||||
- "./pkg/models/console_options.go"
|
||||
- "./pkg/models/decision.go"
|
||||
- "./pkg/models/decisions_delete_request.go"
|
||||
- "./pkg/models/decisions_delete_request_item.go"
|
||||
- "./pkg/models/decisions_stream_response.go"
|
||||
- "./pkg/models/delete_alerts_response.go"
|
||||
- "./pkg/models/delete_decision_response.go"
|
||||
- "./pkg/models/detailed_metrics.go"
|
||||
- "./pkg/models/error_response.go"
|
||||
- "./pkg/models/event.go"
|
||||
- "./pkg/models/flush_decision_response.go"
|
||||
- "./pkg/models/get_alerts_response.go"
|
||||
- "./pkg/models/get_allowlist_response.go"
|
||||
- "./pkg/models/get_allowlists_response.go"
|
||||
- "./pkg/models/get_decisions_response.go"
|
||||
- "./pkg/models/hub_item.go"
|
||||
- "./pkg/models/hub_items.go"
|
||||
- "./pkg/models/lapi_metrics.go"
|
||||
- "./pkg/models/log_processors_metrics.go"
|
||||
- "./pkg/models/meta.go"
|
||||
- "./pkg/models/metrics_agent_info.go"
|
||||
- "./pkg/models/metrics_bouncer_info.go"
|
||||
- "./pkg/models/metrics_detail_item.go"
|
||||
- "./pkg/models/metrics.go"
|
||||
- "./pkg/models/metrics_labels.go"
|
||||
- "./pkg/models/metrics_meta.go"
|
||||
- "./pkg/models/o_sversion.go"
|
||||
- "./pkg/models/remediation_components_metrics.go"
|
||||
- "./pkg/models/source.go"
|
||||
- "./pkg/models/success_response.go"
|
||||
- "./pkg/models/topx_response.go"
|
||||
- "./pkg/models/watcher_auth_request.go"
|
||||
- "./pkg/models/watcher_auth_response.go"
|
||||
- "./pkg/models/watcher_registration_request.go"
|
||||
- "./pkg/protobufs/notifier_grpc.pb.go"
|
||||
- "./pkg/protobufs/notifier.pb.go"
|
||||
|
|
4
.github/generate-codecov-yml.sh
vendored
4
.github/generate-codecov-yml.sh
vendored
|
@ -2,7 +2,7 @@
|
|||
|
||||
# Run this from the repository root:
|
||||
#
|
||||
# .github/generate-codecov-yml.sh >> .github/codecov.yml
|
||||
# .github/generate-codecov-yml.sh > .github/codecov.yml
|
||||
|
||||
cat <<EOT
|
||||
# we measure coverage but don't enforce it
|
||||
|
@ -24,7 +24,7 @@ coverage:
|
|||
ignore:
|
||||
EOT
|
||||
|
||||
find . -name "*.go" | while read -r file; do
|
||||
find . -name "*.go" | sort | while read -r file; do
|
||||
if head -n 1 "$file" | grep -q "Code generated by"; then
|
||||
echo " - \"$file\""
|
||||
fi
|
||||
|
|
2
.github/workflows/go-tests.yml
vendored
2
.github/workflows/go-tests.yml
vendored
|
@ -167,7 +167,7 @@ jobs:
|
|||
|
||||
- name: Generate codecov configuration
|
||||
run: |
|
||||
.github/generate-codecov-yml.sh >> .github/codecov.yml
|
||||
.github/generate-codecov-yml.sh > .github/codecov.yml
|
||||
|
||||
- name: Ensure we can do a dynamic build
|
||||
run: |
|
||||
|
|
|
@ -21,7 +21,7 @@ stages:
|
|||
- task: GoTool@0
|
||||
displayName: "Install Go"
|
||||
inputs:
|
||||
version: '1.24.1'
|
||||
version: '1.24.3'
|
||||
|
||||
- pwsh: |
|
||||
choco install -y make
|
||||
|
|
|
@ -25,7 +25,7 @@ func (cli *cliConfig) showKey(key string) error {
|
|||
}
|
||||
|
||||
opts := []expr.Option{}
|
||||
opts = append(opts, exprhelpers.GetExprOptions(map[string]interface{}{})...)
|
||||
opts = append(opts, exprhelpers.GetExprOptions(map[string]any{})...)
|
||||
opts = append(opts, expr.Env(Env{}))
|
||||
|
||||
program, err := expr.Compile(key, opts...)
|
||||
|
@ -44,7 +44,7 @@ func (cli *cliConfig) showKey(key string) error {
|
|||
// that would break compatibility with previous versions
|
||||
switch output.(type) {
|
||||
case string:
|
||||
fmt.Println(output)
|
||||
fmt.Fprintln(os.Stdout, output)
|
||||
default:
|
||||
litter.Dump(output)
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ func (cli *cliConfig) showKey(key string) error {
|
|||
return fmt.Errorf("failed to serialize configuration: %w", err)
|
||||
}
|
||||
|
||||
fmt.Println(string(data))
|
||||
fmt.Fprintln(os.Stdout, string(data))
|
||||
}
|
||||
|
||||
return nil
|
||||
|
@ -67,6 +67,7 @@ func (cli *cliConfig) template() string {
|
|||
- Configuration Folder : {{.ConfigPaths.ConfigDir}}
|
||||
- Data Folder : {{.ConfigPaths.DataDir}}
|
||||
- Hub Folder : {{.ConfigPaths.HubDir}}
|
||||
- Notification Folder : {{.ConfigPaths.NotificationDir}}
|
||||
- Simulation File : {{.ConfigPaths.SimulationFilePath}}
|
||||
{{- end }}
|
||||
|
||||
|
@ -216,14 +217,14 @@ func (cli *cliConfig) show() error {
|
|||
return fmt.Errorf("failed to serialize configuration: %w", err)
|
||||
}
|
||||
|
||||
fmt.Println(string(data))
|
||||
fmt.Fprintln(os.Stdout, string(data))
|
||||
case "raw":
|
||||
data, err := yaml.Marshal(cfg)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to serialize configuration: %w", err)
|
||||
}
|
||||
|
||||
fmt.Println(string(data))
|
||||
fmt.Fprintln(os.Stdout, string(data))
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
@ -70,7 +70,7 @@ func (cli *cliNotifications) NewCommand() *cobra.Command {
|
|||
return fmt.Errorf("loading api client: %w", err)
|
||||
}
|
||||
|
||||
return require.Notifications(cfg)
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -176,7 +176,7 @@ func (cli *cliNotifications) newListCmd() *cobra.Command {
|
|||
if err != nil {
|
||||
return fmt.Errorf("failed to serialize notification configuration: %w", err)
|
||||
}
|
||||
fmt.Printf("%s", string(x))
|
||||
fmt.Fprint(os.Stdout, string(x))
|
||||
} else if cfg.Cscli.Output == "raw" {
|
||||
csvwriter := csv.NewWriter(os.Stdout)
|
||||
err := csvwriter.Write([]string{"Name", "Type", "Profile name"})
|
||||
|
@ -223,19 +223,19 @@ func (cli *cliNotifications) newInspectCmd() *cobra.Command {
|
|||
return fmt.Errorf("plugin '%s' does not exist or is not active", args[0])
|
||||
}
|
||||
if cfg.Cscli.Output == "human" || cfg.Cscli.Output == "raw" {
|
||||
fmt.Printf(" - %15s: %15s\n", "Type", ncfg.Config.Type)
|
||||
fmt.Printf(" - %15s: %15s\n", "Name", ncfg.Config.Name)
|
||||
fmt.Printf(" - %15s: %15s\n", "Timeout", ncfg.Config.TimeOut)
|
||||
fmt.Printf(" - %15s: %15s\n", "Format", ncfg.Config.Format)
|
||||
fmt.Fprintf(os.Stdout, " - %15s: %15s\n", "Type", ncfg.Config.Type)
|
||||
fmt.Fprintf(os.Stdout, " - %15s: %15s\n", "Name", ncfg.Config.Name)
|
||||
fmt.Fprintf(os.Stdout, " - %15s: %15s\n", "Timeout", ncfg.Config.TimeOut)
|
||||
fmt.Fprintf(os.Stdout, " - %15s: %15s\n", "Format", ncfg.Config.Format)
|
||||
for k, v := range ncfg.Config.Config {
|
||||
fmt.Printf(" - %15s: %15v\n", k, v)
|
||||
fmt.Fprintf(os.Stdout, " - %15s: %15v\n", k, v)
|
||||
}
|
||||
} else if cfg.Cscli.Output == "json" {
|
||||
x, err := json.MarshalIndent(cfg, "", " ")
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to serialize notification configuration: %w", err)
|
||||
}
|
||||
fmt.Printf("%s", string(x))
|
||||
fmt.Fprint(os.Stdout, string(x))
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
@ -74,14 +74,6 @@ func DB(c *csconfig.Config) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func Notifications(c *csconfig.Config) error {
|
||||
if c.ConfigPaths.NotificationDir == "" {
|
||||
return errors.New("config_paths.notification_dir is not set in crowdsec config")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func HubDownloader(ctx context.Context, c *csconfig.Config) *cwhub.Downloader {
|
||||
// set branch in config, and log if necessary
|
||||
branch := HubBranch(ctx, c)
|
||||
|
|
|
@ -32,10 +32,6 @@ func initAPIServer(ctx context.Context, cConfig *csconfig.Config) (*apiserver.AP
|
|||
return nil, errors.New("plugins are enabled, but the plugin_config section is missing in the configuration")
|
||||
}
|
||||
|
||||
if cConfig.ConfigPaths.NotificationDir == "" {
|
||||
return nil, errors.New("plugins are enabled, but config_paths.notification_dir is not defined")
|
||||
}
|
||||
|
||||
if cConfig.ConfigPaths.PluginDir == "" {
|
||||
return nil, errors.New("plugins are enabled, but config_paths.plugin_dir is not defined")
|
||||
}
|
||||
|
|
4
go.mod
4
go.mod
|
@ -1,6 +1,6 @@
|
|||
module github.com/crowdsecurity/crowdsec
|
||||
|
||||
go 1.24.1
|
||||
go 1.24.3
|
||||
|
||||
require (
|
||||
entgo.io/ent v0.14.2
|
||||
|
@ -33,7 +33,7 @@ require (
|
|||
github.com/docker/docker v27.3.1+incompatible
|
||||
github.com/docker/go-connections v0.5.0
|
||||
github.com/docker/go-units v0.5.0 // indirect
|
||||
github.com/expr-lang/expr v1.16.9
|
||||
github.com/expr-lang/expr v1.17.2
|
||||
github.com/fatih/color v1.18.0
|
||||
github.com/fsnotify/fsnotify v1.7.0
|
||||
github.com/gin-gonic/gin v1.10.0
|
||||
|
|
4
go.sum
4
go.sum
|
@ -134,8 +134,8 @@ github.com/docker/go-units v0.3.3/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDD
|
|||
github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
|
||||
github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4=
|
||||
github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
|
||||
github.com/expr-lang/expr v1.16.9 h1:WUAzmR0JNI9JCiF0/ewwHB1gmcGw5wW7nWt8gc6PpCI=
|
||||
github.com/expr-lang/expr v1.16.9/go.mod h1:8/vRC7+7HBzESEqt5kKpYXxrxkr31SaO8r40VO/1IT4=
|
||||
github.com/expr-lang/expr v1.17.2 h1:o0A99O/Px+/DTjEnQiodAgOIK9PPxL8DtXhBRKC+Iso=
|
||||
github.com/expr-lang/expr v1.17.2/go.mod h1:8/vRC7+7HBzESEqt5kKpYXxrxkr31SaO8r40VO/1IT4=
|
||||
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
|
||||
github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM=
|
||||
github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU=
|
||||
|
|
|
@ -19,10 +19,15 @@ type ConfigurationPaths struct {
|
|||
|
||||
func (c *Config) loadConfigurationPaths() error {
|
||||
var err error
|
||||
|
||||
if c.ConfigPaths == nil {
|
||||
return errors.New("no configuration paths provided")
|
||||
}
|
||||
|
||||
if c.ConfigPaths.ConfigDir == "" {
|
||||
c.ConfigPaths.ConfigDir = filepath.Dir(c.FilePath)
|
||||
}
|
||||
|
||||
if c.ConfigPaths.DataDir == "" {
|
||||
return errors.New("please provide a data directory with the 'data_dir' directive in the 'config_paths' section")
|
||||
}
|
||||
|
@ -35,6 +40,10 @@ func (c *Config) loadConfigurationPaths() error {
|
|||
c.ConfigPaths.HubIndexFile = filepath.Join(c.ConfigPaths.HubDir, ".index.json")
|
||||
}
|
||||
|
||||
if c.ConfigPaths.NotificationDir == "" {
|
||||
c.ConfigPaths.NotificationDir = filepath.Join(c.ConfigPaths.ConfigDir, "notifications")
|
||||
}
|
||||
|
||||
if c.ConfigPaths.PatternDir == "" {
|
||||
c.ConfigPaths.PatternDir = filepath.Join(c.ConfigPaths.ConfigDir, "patterns")
|
||||
}
|
||||
|
@ -53,6 +62,7 @@ func (c *Config) loadConfigurationPaths() error {
|
|||
if *k == "" {
|
||||
continue
|
||||
}
|
||||
|
||||
*k, err = filepath.Abs(*k)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get absolute path of '%s': %w", *k, err)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
//go:build expr_debug
|
||||
|
||||
package exprhelpers
|
||||
|
||||
import (
|
||||
|
@ -273,6 +274,20 @@ func TestBaseDbg(t *testing.T) {
|
|||
{Code: "and", CodeDepth: 0, JumpIf: true, IfFalse: true, StrConditionResult: "false", ConditionResult: boolPtr(false), Finalized: true},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "if",
|
||||
Expr: `if base_int != 42 {
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}`,
|
||||
Env: defaultEnv,
|
||||
ExpectedOutputs: []OpOutput{
|
||||
{Code: "!= 42 {", CodeDepth: 0, Negated: true, Comparison: true, Left: "42", Right: "42", StrConditionResult: "[true]", ConditionResult: boolPtr(true), Finalized: true},
|
||||
{Code: "if base_int != 42 {", CodeDepth: 0, ConditionResult: boolPtr(false), Finalized: false, IfFalse: true, JumpIf: true, StrConditionResult: "false"},
|
||||
{Code: "false }", CodeDepth: 0, StrConditionResult: "false", Condition: true, ConditionResult: boolPtr(false), Finalized: true},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
logger := log.WithField("test", "exprhelpers")
|
||||
|
|
|
@ -147,6 +147,11 @@ teardown() {
|
|||
|
||||
# defaults
|
||||
|
||||
config_set 'del(.config_paths.config_dir)'
|
||||
rune -0 cscli config show --key Config.ConfigPaths.ConfigDir
|
||||
assert_output "$configdir"
|
||||
echo "$config" > "$CONFIG_YAML"
|
||||
|
||||
config_set 'del(.config_paths.hub_dir)'
|
||||
rune -0 cscli hub list
|
||||
rune -0 cscli config show --key Config.ConfigPaths.HubDir
|
||||
|
|
|
@ -12,6 +12,9 @@ setup_file() {
|
|||
|
||||
PROFILES_PATH=$(config_get '.api.server.profiles_path')
|
||||
export PROFILES_PATH
|
||||
|
||||
CONFIG_DIR=$(dirname "$CONFIG_YAML")
|
||||
export CONFIG_DIR
|
||||
}
|
||||
|
||||
teardown_file() {
|
||||
|
@ -72,7 +75,6 @@ teardown() {
|
|||
}
|
||||
|
||||
@test "duplicate notification config" {
|
||||
CONFIG_DIR=$(dirname "$CONFIG_YAML")
|
||||
# email_default has two configurations
|
||||
rune -0 yq -i '.name="email_default"' "$CONFIG_DIR/notifications/http.yaml"
|
||||
# enable a notification, otherwise plugins are ignored
|
||||
|
@ -110,10 +112,8 @@ teardown() {
|
|||
|
||||
@test "config.yaml: missing config_paths.notification_dir" {
|
||||
config_set 'del(.config_paths.notification_dir)'
|
||||
config_set "$PROFILES_PATH" '.notifications=["http_default"]'
|
||||
rune -0 wait-for \
|
||||
--err "api server init: plugins are enabled, but config_paths.notification_dir is not defined" \
|
||||
"$CROWDSEC"
|
||||
rune -0 cscli config show --key Config.ConfigPaths.NotificationDir
|
||||
assert_output "$CONFIG_DIR/notifications"
|
||||
}
|
||||
|
||||
@test "config.yaml: missing config_paths.plugin_dir" {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue