Module: PackageProtections::ProtectionInterface

Instance Method Summary collapse

Instance Method Details

#default_behaviorObject



38
39
40
41
42
43
44
45
# File 'lib/package_protections/protection_interface.rb', line 38

def default_behavior
  # The default behavior here is that we simply return the `fail_on_new` protection.
  # In some cases, this protection may not actually be supported. For example, `OutgoingPrivacyProtection` raises if the user has `enforce_privacy: false`
  # Error messages should provide enough clarity to either:
  # A) Know which protection to explicitly set to fail_never
  # B) Know how to change conditions to allow protection to be supported (i.e. set enforce dependencies to be true)
  ViolationBehavior::FailOnNew
end

#get_offenses(protected_packages, new_violations) ⇒ Object



20
21
22
23
24
25
26
27
# File 'lib/package_protections/protection_interface.rb', line 20

def get_offenses(protected_packages, new_violations)
  [
    # First we get all offenses for new violations
    *get_offenses_for_new_violations(new_violations),
    # Then we separately look at TODO lists and add violations if there are no issues
    *get_offenses_for_existing_violations(protected_packages)
  ].sort_by(&:message)
end

#get_offenses_for_existing_violations(protected_packages) ⇒ Object



59
# File 'lib/package_protections/protection_interface.rb', line 59

def get_offenses_for_existing_violations(protected_packages); end

#get_offenses_for_new_violations(new_violations) ⇒ Object



52
# File 'lib/package_protections/protection_interface.rb', line 52

def get_offenses_for_new_violations(new_violations); end

#humanized_protection_descriptionObject



68
# File 'lib/package_protections/protection_interface.rb', line 68

def humanized_protection_description; end

#humanized_protection_nameObject



65
# File 'lib/package_protections/protection_interface.rb', line 65

def humanized_protection_name; end

#identifierObject



62
# File 'lib/package_protections/protection_interface.rb', line 62

def identifier; end

#supports_violation_behavior?(behavior, package) ⇒ Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/package_protections/protection_interface.rb', line 33

def supports_violation_behavior?(behavior, package)
  unmet_preconditions_for_behavior(behavior, package).nil?
end

#unmet_preconditions_for_behavior(behavior, package) ⇒ Object



30
# File 'lib/package_protections/protection_interface.rb', line 30

def unmet_preconditions_for_behavior(behavior, package); end