Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 10 additions & 2 deletions scripts/plan-ruleset-constraint-repair.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,16 @@ module RulesetConstraintRepair
RETIRED = %w[update required_deployments code_quality code_coverage].freeze
WRITABLE = %w[name target enforcement conditions bypass_actors rules].freeze

# Supply an app ID only after GitHub rejects it as no longer installed. Removing
# a stale bypass tightens access; never infer app availability from its name.
# Build a new ruleset update body with the four retired constraints removed,
# preserving the other writable fields and leaving +source+ unchanged.
#
# When +uninstalled_app_id+ is supplied, also remove only that integration's
# bypass. Supply an ID only after GitHub rejects it as no longer installed;
# never infer app availability from its name.
#
# Raises ArgumentError unless the source is an active default-branch ruleset
# with pull-request protection, or if the requested integration ID is invalid
# or absent. A supplied ID also requires +source+ to contain +bypass_actors+.
def self.plan(source, uninstalled_app_id: nil)
unless source.is_a?(Hash) && source['target'] == 'branch' && source['enforcement'] == 'active' &&
source.dig('conditions', 'ref_name', 'include') == ['~DEFAULT_BRANCH'] &&
Expand Down
10 changes: 10 additions & 0 deletions scripts/reconcile-scorecard-actions-lock.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
module ScorecardActionsLock
PIN_MESSAGE = /\Ascore is \d+: (?:GitHub-owned |third-party )?GitHubAction not pinned by hash\n/

# Return the one-based line numbers of remote GitHub Action +uses+ entries in
# the workflow. Local actions, containers and text containing +uses+ are
# excluded.
def self.action_lines(path)
lines = []
visit = lambda do |node|
Expand All @@ -27,6 +30,13 @@ def self.action_lines(path)
lines
end

# Remove Scorecard action-pin findings only when they identify a remote action
# entry in a regular workflow below +root+ and native action-lock verification
# succeeds. The supplied SARIF document is updated in place and returned with
# audit records for removed findings.
#
# Invokes +gh actions-lock+ once per eligible workflow. Raises when the SARIF
# structure or native verification result is invalid, or verification fails.
def self.reconcile(document, root)
raise 'Expected a SARIF 2.1.0 document with runs' unless document.is_a?(Hash) &&
document['version'] == '2.1.0' && document['runs'].is_a?(Array) && !document['runs'].empty?
Expand Down
Loading