Offer business logic scanning on Self-Managed

Problem

Business logic scanning (the bl_security foundational flow) is offered on GitLab.com and on GitLab Dedicated, but not on GitLab Self-Managed.

Three things block it on Self-Managed:

  • The flow's available_on does not list :self_managed. A validation also refuses self_managed together with dedicated_enabled_instances.
  • The flow only runs on GitLab-hosted runners, and Self-Managed has none.
  • Rails never checks whether GitLab enabled the instance. The Duo Workflow Service refuses bl_security for any instance it has not enabled. Listing the flow alone would show it, then fail every run.

Impact

Self-Managed Ultimate customers can run business logic scanning with the default model once GitLab enables their instance.

Enabling a customer is an ops change, not code: their instance UUID goes under bl_security in the Duo Workflow Service's DUO_WORKFLOW_AUTH__ENABLED_FLOW_INSTANCE_UIDS (with DUO_WORKFLOW_AUTH__ENFORCE_FLOW_ENABLEMENT on). This is the same path Dedicated uses.

Case Today on master With this MR
Self-Managed, instance enabled by GitLab, both flags + instance beta setting on Hidden Available; findings reach the MR widget and Vulnerability Report
Self-Managed, instance not enabled Hidden Hidden; starting a run returns 403
Self-Managed, bl_security_analyzer flag or instance beta setting off Hidden Hidden
Self-Managed, instance enabled, agentic_analyzer_security_ingestion off Hidden BLSA runs; findings are not ingested into the MR widget, Vulnerability Report or approval policies
Self-Managed runner None accepted Instance or top-level group runner with the gitlab--duo tag
GitLab.com (regression row) Available Unchanged
Dedicated, enabled / not enabled (regression row) Available / hidden Unchanged

What changes

  • Availability: bl_security lists :self_managed. On Self-Managed it uses the same per-instance gate as Dedicated (per_instance_gate_applies?). It is available only where GitLab enabled the instance, plus the bl_security_analyzer flag and the instance beta setting. On Dedicated, enablement still stands in for the flag.
  • Findings ingestion: where the per-instance gate applies, Security::AgenticAnalyzer.enabled? also needs the flow enabled, checked on the top-level group. On Self-Managed the agentic_analyzer_security_ingestion flag still applies. Only Dedicated skips it, because feature flags can't be set there (FoundationalFlow#enablement_replaces_feature_flags?).
  • Runners: new FoundationalFlow#gitlab_hosted_runner_required? is false on Self-Managed. RunnerValidator then accepts the customer's instance or top-level group runners. The job still uses GitLab's pinned image and duo binary. The trusted flow_config_id claim follows the same rule, so Self-Managed jobs never carry it.
  • Validation: drops the branch that refused self_managed with dedicated_enabled_instances. Any flow may now list both.
  • Naming: opted_in_on_dedicated? becomes beta_opted_in?, since it now also runs on Self-Managed.
  • Docs: Self-Managed added as an offering, with its prerequisites.

New network call

A Self-Managed instance with the beta setting and the flag on now asks the AI gateway which flows GitLab enabled for it (EnabledFlowsClient, GET /v1/flows/enabled).

  • The flag is checked first, so instances with either setting off make no call.
  • Answers are cached for 30 minutes. Failures keep the last good answer for up to a day, otherwise the flow stays off.
  • Instances with an offline cloud license skip the call.
  • Shipped Self-Managed versions depend on the endpoint path, the enabled_flows key and the duo_agent_platform token scope.

Backward compatibility

  • Only bl_security changes. It is the only flow that sets gitlab_hosted_runner_only or lists dedicated_enabled_instances. RunnerValidator and the removed validation cannot change any other flow.
  • GitLab.com and Dedicated: unchanged, covered by existing and new regression rows.
  • AgenticAnalyzer.enabled? consumers (ingestion, MR widget comparison, policy sync): on Dedicated it now passes the top-level group, not :instance. The Dedicated path ignores the actor, so nothing changes.
  • FeatureSetting.allowed_features on Self-Managed: now matches Dedicated. An enabled instance with the beta setting and the bl_security_analyzer flag on gets bl_security without a separate testing-terms acceptance.
  • Group selections: a group that selected the flow keeps it when the instance is not enabled, as on Dedicated. The flow just doesn't run.
  • Specs: specs default to Self-Managed. Specs that turned bl_security on by flag alone now include a new shared context, with bl_security enabled for the instance, which stubs the enabled-flows lookup. This is most of the diff.

Out of scope / follow-ups

  • Mythos stays unavailable on Self-Managed. Its model restriction in the AI gateway is untouched.
  • Offline and GitLab Duo Self-Hosted instances are not supported. The runner needs gitlab.com and registry.gitlab.com, and a customer-run Duo Workflow Service refuses the flow.
  • Naming: gitlab_hosted_runner_only and :dedicated_enabled_instances now also cover Self-Managed. Renaming them is a follow-up. On Self-Managed, refusing IDE and CLI runs follows the duo_hosted_runner_only_refusal flag, which is off by default.
  • Spec cleanup: some ingestion specs turn off both the ingestion flag and the instance enablement. On Self-Managed the flag alone is enough. Simplifying them is a follow-up.
  • ai-assist: the GATED_FLOWS comment in lib/flow_enablement.py says only GitLab.com flows belong there. A follow-up there corrects it.

Verification

On a Self-Managed GDK at the current head, with a local Duo Workflow Service (per-instance enforcement on) and the default model:

  • Instance enabled, both flags on: BLSA ran on an instance runner and found a cross-customer authorization bug, shown in the MR security widget. After merge, a default-branch scan added it to the Vulnerability Report.
  • Instance enabled, agentic_analyzer_security_ingestion off: BLSA still runs, but nothing new reaches the MR widget or the Vulnerability Report. Turning the flag on ingests the same findings.
  • Instance not enabled: the flow is unavailable. Starting it returns 403, with no workflow left behind.
  • Specs: about 2,650 examples in the affected spec files pass. Reverting the gate fails 11 examples. ingestion_spec, agentic_analyzer_policy_visibility_spec and agentic_analyzer_mr_widget_e2e_spec still pass with it reverted, because they stub the gate.

Context

Closes #638992 (closed)

🤖 Generated with Claude Code

Edited by Meir Benayoun

Merge request reports

Loading
Loading