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.

[View source]

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

def initialize(file_path)
   @delegate_sd_obj = file_path
end

Instance Method Details

#binread(**args) ⇒ Object

[View source]

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

def binread(**args)
   verify_permissions!

   @delegate_sd_obj.binread(**args)
end

#read(**args) ⇒ Object

[View source]

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

def read(**args)
   verify_permissions!

   @delegate_sd_obj.read(**args)
end