Class: Marshalsea::Marshal::Limits

Inherits:
Object
  • Object
show all
Defined in:
lib/marshalsea/marshal/limits.rb

Constant Summary collapse

DEFAULT_MAX_BYTES =
1_048_576
DEFAULT_MAX_DEPTH =
64
DEFAULT_MAX_NODES =
10_000
DEFAULT_MAX_REGISTERED_OBJECTS =
4_096
DEFAULT_MAX_SYMBOL_DEFINITIONS =
256
DEFAULT_MAX_COLLECTION_ENTRIES =
1_024
DEFAULT_MAX_SCALAR_BYTES =
262_144
DEFAULT_MAX_TOTAL_SCALAR_BYTES =
524_288
2_048
DEFAULT_MAX_SYMBOL_REFERENCES =
2_048
DEFAULT_MAX_SYMBOL_NAME_BYTES =
1_024
DEFAULT_MAX_CLASS_NAME_BYTES =
1_024
DEFAULT_MAX_INSTANCE_VARIABLES =
256
DEFAULT_MAX_STRUCT_MEMBERS =
256
ROLE_BYTES =
"stream bytes"
ROLE_NODES =
"nodes"
ROLE_REGISTERED =
"registered objects"
ROLE_SYMBOLS =
"symbol definitions"
ROLE_ENTRIES =
"collection entries"
ROLE_SCALAR =
"scalar bytes"
ROLE_TOTAL_SCALAR =
"total scalar bytes"
"object links"
ROLE_SYMBOL_REFERENCES =
"symbol references"
ROLE_SYMBOL_NAME =
"symbol name bytes"
ROLE_CLASS_NAME =
"class name bytes"
ROLE_INSTANCE_VARIABLES =
"instance variables"
ROLE_STRUCT_MEMBERS =
"struct members"
UNBOUNDED =
Float::INFINITY
STACK_SAFE_MAX_DEPTH =
Constants::DEFAULT_MAX_DEPTH

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(max_bytes: DEFAULT_MAX_BYTES, max_depth: DEFAULT_MAX_DEPTH, max_nodes: DEFAULT_MAX_NODES, max_registered_objects: DEFAULT_MAX_REGISTERED_OBJECTS, max_symbol_definitions: DEFAULT_MAX_SYMBOL_DEFINITIONS, max_collection_entries: DEFAULT_MAX_COLLECTION_ENTRIES, max_scalar_bytes: DEFAULT_MAX_SCALAR_BYTES, max_total_scalar_bytes: DEFAULT_MAX_TOTAL_SCALAR_BYTES, max_object_links: DEFAULT_MAX_OBJECT_LINKS, max_symbol_references: DEFAULT_MAX_SYMBOL_REFERENCES, max_symbol_name_bytes: DEFAULT_MAX_SYMBOL_NAME_BYTES, max_class_name_bytes: DEFAULT_MAX_CLASS_NAME_BYTES, max_instance_variables: DEFAULT_MAX_INSTANCE_VARIABLES, max_struct_members: DEFAULT_MAX_STRUCT_MEMBERS) ⇒ Limits

Returns a new instance of Limits.



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/marshalsea/marshal/limits.rb', line 45

def initialize(
  max_bytes: DEFAULT_MAX_BYTES,
  max_depth: DEFAULT_MAX_DEPTH,
  max_nodes: DEFAULT_MAX_NODES,
  max_registered_objects: DEFAULT_MAX_REGISTERED_OBJECTS,
  max_symbol_definitions: DEFAULT_MAX_SYMBOL_DEFINITIONS,
  max_collection_entries: DEFAULT_MAX_COLLECTION_ENTRIES,
  max_scalar_bytes: DEFAULT_MAX_SCALAR_BYTES,
  max_total_scalar_bytes: DEFAULT_MAX_TOTAL_SCALAR_BYTES,
  max_object_links: DEFAULT_MAX_OBJECT_LINKS,
  max_symbol_references: DEFAULT_MAX_SYMBOL_REFERENCES,
  max_symbol_name_bytes: DEFAULT_MAX_SYMBOL_NAME_BYTES,
  max_class_name_bytes: DEFAULT_MAX_CLASS_NAME_BYTES,
  max_instance_variables: DEFAULT_MAX_INSTANCE_VARIABLES,
  max_struct_members: DEFAULT_MAX_STRUCT_MEMBERS
)
  @max_bytes = max_bytes
  @max_depth = max_depth
  @max_nodes = max_nodes
  @max_registered_objects = max_registered_objects
  @max_symbol_definitions = max_symbol_definitions
  @max_collection_entries = max_collection_entries
  @max_scalar_bytes = max_scalar_bytes
  @max_total_scalar_bytes = max_total_scalar_bytes
  @max_object_links = max_object_links
  @max_symbol_references = max_symbol_references
  @max_symbol_name_bytes = max_symbol_name_bytes
  @max_class_name_bytes = max_class_name_bytes
  @max_instance_variables = max_instance_variables
  @max_struct_members = max_struct_members
end

Instance Attribute Details

#max_bytesObject (readonly)

Returns the value of attribute max_bytes.



39
40
41
# File 'lib/marshalsea/marshal/limits.rb', line 39

def max_bytes
  @max_bytes
end

#max_class_name_bytesObject (readonly)

Returns the value of attribute max_class_name_bytes.



39
40
41
# File 'lib/marshalsea/marshal/limits.rb', line 39

def max_class_name_bytes
  @max_class_name_bytes
end

#max_collection_entriesObject (readonly)

Returns the value of attribute max_collection_entries.



39
40
41
# File 'lib/marshalsea/marshal/limits.rb', line 39

def max_collection_entries
  @max_collection_entries
end

#max_depthObject (readonly)

Returns the value of attribute max_depth.



39
40
41
# File 'lib/marshalsea/marshal/limits.rb', line 39

def max_depth
  @max_depth
end

#max_instance_variablesObject (readonly)

Returns the value of attribute max_instance_variables.



39
40
41
# File 'lib/marshalsea/marshal/limits.rb', line 39

def max_instance_variables
  @max_instance_variables
end

#max_nodesObject (readonly)

Returns the value of attribute max_nodes.



39
40
41
# File 'lib/marshalsea/marshal/limits.rb', line 39

def max_nodes
  @max_nodes
end

Returns the value of attribute max_object_links.



39
40
41
# File 'lib/marshalsea/marshal/limits.rb', line 39

def max_object_links
  @max_object_links
end

#max_registered_objectsObject (readonly)

Returns the value of attribute max_registered_objects.



39
40
41
# File 'lib/marshalsea/marshal/limits.rb', line 39

def max_registered_objects
  @max_registered_objects
end

#max_scalar_bytesObject (readonly)

Returns the value of attribute max_scalar_bytes.



39
40
41
# File 'lib/marshalsea/marshal/limits.rb', line 39

def max_scalar_bytes
  @max_scalar_bytes
end

#max_struct_membersObject (readonly)

Returns the value of attribute max_struct_members.



39
40
41
# File 'lib/marshalsea/marshal/limits.rb', line 39

def max_struct_members
  @max_struct_members
end

#max_symbol_definitionsObject (readonly)

Returns the value of attribute max_symbol_definitions.



39
40
41
# File 'lib/marshalsea/marshal/limits.rb', line 39

def max_symbol_definitions
  @max_symbol_definitions
end

#max_symbol_name_bytesObject (readonly)

Returns the value of attribute max_symbol_name_bytes.



39
40
41
# File 'lib/marshalsea/marshal/limits.rb', line 39

def max_symbol_name_bytes
  @max_symbol_name_bytes
end

#max_symbol_referencesObject (readonly)

Returns the value of attribute max_symbol_references.



39
40
41
# File 'lib/marshalsea/marshal/limits.rb', line 39

def max_symbol_references
  @max_symbol_references
end

#max_total_scalar_bytesObject (readonly)

Returns the value of attribute max_total_scalar_bytes.



39
40
41
# File 'lib/marshalsea/marshal/limits.rb', line 39

def max_total_scalar_bytes
  @max_total_scalar_bytes
end

Class Method Details

.permissiveObject



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/marshalsea/marshal/limits.rb', line 79

def self.permissive
  new(
    max_bytes: UNBOUNDED,
    max_depth: STACK_SAFE_MAX_DEPTH,
    max_nodes: UNBOUNDED,
    max_registered_objects: UNBOUNDED,
    max_symbol_definitions: UNBOUNDED,
    max_collection_entries: UNBOUNDED,
    max_scalar_bytes: UNBOUNDED,
    max_total_scalar_bytes: UNBOUNDED,
    max_object_links: UNBOUNDED,
    max_symbol_references: UNBOUNDED,
    max_symbol_name_bytes: UNBOUNDED,
    max_class_name_bytes: UNBOUNDED,
    max_instance_variables: UNBOUNDED,
    max_struct_members: UNBOUNDED
  )
end