Class: DCCSCR::Whitelist

Inherits:
Object
  • Object
show all
Defined in:
lib/dccscr/whitelist.rb

Overview

Class to download the dccscr_whitelist repo and store greylist entries.

Defined Under Namespace

Classes: Entry, UpdateAllowlistWithDCCSCR

Constant Summary collapse

UPSTREAM_REPO =
'https://repo1.dso.mil/dsop/dccscr-whitelists.git'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path: nil, repo: nil, clone: true, clone_options: '--depth 1') ⇒ Whitelist

Returns a new instance of Whitelist.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/dccscr/whitelist.rb', line 16

def initialize(path: nil, repo: nil, clone: true, clone_options: '--depth 1')
  if path
    @path = path
  else
    @path = Dir.mktmpdir
    at_exit { FileUtils.remove_entry @path }
  end

  if repo
    @repo = repo
  else
    @repo = UPSTREAM_REPO
  end

  clone_repo(clone_options) if clone

  @entries = {}
end

Instance Attribute Details

#entriesObject (readonly)

Returns the value of attribute entries.



14
15
16
# File 'lib/dccscr/whitelist.rb', line 14

def entries
  @entries
end

#pathObject (readonly)

Returns the value of attribute path.



14
15
16
# File 'lib/dccscr/whitelist.rb', line 14

def path
  @path
end

#repoObject (readonly)

Returns the value of attribute repo.



14
15
16
# File 'lib/dccscr/whitelist.rb', line 14

def repo
  @repo
end

Instance Method Details

#[](subpath) ⇒ Object



35
36
37
# File 'lib/dccscr/whitelist.rb', line 35

def [](subpath)
  entries[subpath] ||= Entry.new(whitelist: self, subpath: subpath)
end