Class: Invar::PrivateFile

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/invar/private_file.rb

Overview

Verifies a file is secure

Defined Under Namespace

Classes: FilePermissionsError

Constant Summary collapse

PERMISSIONS_MASK =

Mask for limiting to the lowest three octal digits (which store permissions)

0o777
ALLOWED_USER_MODES =
[0o600, 0o400].freeze
ALLOWED_GROUP_MODES =
[0o060, 0o040, 0o000].freeze
DEFAULT_PERMISSIONS =
0o600
ALLOWED_MODES =

Allowed permissions modes for lockfile. Readable or read-writable by the user or group only

ALLOWED_USER_MODES.product(ALLOWED_GROUP_MODES).collect do |u, g|
   u | g # bitwise OR
end.freeze

Instance Method Summary collapse

Constructor Details

#initialize(file_path) ⇒ PrivateFile

Returns a new instance of PrivateFile.



28
29
30
# File 'lib/invar/private_file.rb', line 28

def initialize(file_path)
   @delegate_sd_obj = file_path
end

Instance Method Details

#binread(**args) ⇒ Object



38
39
40
41
42
# File 'lib/invar/private_file.rb', line 38

def binread(**args)
   verify_permissions!

   @delegate_sd_obj.binread(**args)
end

#read(**args) ⇒ Object



32
33
34
35
36
# File 'lib/invar/private_file.rb', line 32

def read(**args)
   verify_permissions!

   @delegate_sd_obj.read(**args)
end