Add a WIP flag for package version rule work

What does this MR do and why?

Package version rule work lands as several merge requests, and none of them is useful until the last one. This MR adds a work-in-progress flag, dependency_firewall_package_version, that is never enabled, and gates the existing package version rule code on it. The later merge requests in the stack gate themselves on it too, so the whole feature stays hidden until it is complete. The last merge request in the stack removes the flag.

  • The flag has type wip and is off by default.
  • Security::DependencyFirewall::Availability.package_version_enabled? checks it against the top-level group, like the other dependency firewall predicates. package_version_rules_enabled? requires both this flag and the dependency firewall access flag.
  • The group and project policies controllers push the flag to the frontend as dependencyFirewallPackageVersion, next to the access flag.
  • Package version rules are active only when package_version_rules_enabled? is true:
    • PolicyEvaluator skips package version rules otherwise.
    • Security::Policy leaves package version rules out when syncing otherwise.
    • The policy editor shows the package version rule type and its subtitle only when both frontend flags are on.

Groups that have only the access flag lose package version rules until they also get the new flag. Policies synced while the flag is off get their package version rules persisted on the next policy sync after the flag is enabled.

References

Screenshots or screen recordings

No visible change while the flag is off, which is the default.

Before After
n/a n/a

How to set up and validate locally

  1. In a Rails console, enable the access flag and the new flag for a top-level group:
    group = Group.find_by_full_path('<top-level-group>')
    Feature.enable(:dependency_firewall_access, group)
    Feature.enable(:dependency_firewall_package_version, group)
  2. Open the group's policies page, create a Dependency Firewall policy, and confirm the package version rule type is offered. In the browser console this prints true:
    window.gon.features.dependencyFirewallPackageVersion
  3. Disable the new flag and reload. The package version rule type is gone and the value prints false:
    Feature.disable(:dependency_firewall_package_version, group)

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Hannah Baker

Merge request reports

Loading
Loading