arbac_verifier 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9e8293d45df6e6ac48d7923723d3b04899292bf34bf0696046bae3ddd2eb6dba
4
- data.tar.gz: 84e90713d08d36b339de962531f7494f15580e59f10a6d6ebed5a2ed18f8a5b0
3
+ metadata.gz: 1e6677babd9700f22f8a74f28c699d7c94d833aecce94a077ff497a4f8f93cbf
4
+ data.tar.gz: bfbdf60e6169c04006cc21fbde36a740d940ca904e08560759823cd76c9cf30d
5
5
  SHA512:
6
- metadata.gz: d781d6c1a8a0de56210e9c47abf4eae12e0559704309f99a6fe6a217dfe94774028004e83803261344280344b0d129a0caeac6290c0866684c18bd72f7b3f279
7
- data.tar.gz: 4f585bf557ccbe4ba22d3d14b622a136731c14383c7c1edd9566e0141001512468b81c79386c9faae7e519d02b12d1371d06dd045bb569b4959a2c150eef5bbd
6
+ metadata.gz: 5c6bc1f6256a7c0e17f804153c0d657f706c0a9e531df983e54792473c510636641a1dfe8e295cb44d3500f9ddca45900bd32b90ed9cbf38781dd3444993646d
7
+ data.tar.gz: 1f8365ff6a3b127cfa620ffe37831f5a04b1b3d98646d93b3458a0dd6d73ebb381d7a229db8fc263d9bf1b3ce43304aa1d462abc12fa34ac9075e05e7d9764f6
@@ -29,9 +29,7 @@ class ArbacInstance
29
29
 
30
30
  sig { params(params: T.any(Symbol, T::Set[String], T::Set[Symbol], T::Set[UserRole], T::Set[CanAssignRule], T::Set[CanRevokeRule], String)).void }
31
31
  def initialize(**params)
32
- unless params[:path].nil?
33
- initialize_by_file_path(T.cast(params[:path], String))
34
- else
32
+ if params[:path].nil?
35
33
  initialize_by_attributes(
36
34
  T.cast(params[:goal], Symbol),
37
35
  T.cast(params[:roles], T::Set[Symbol]),
@@ -40,6 +38,8 @@ class ArbacInstance
40
38
  T.cast(params[:can_assign_rules], T::Set[CanAssignRule]),
41
39
  T.cast(params[:can_revoke_rules], T::Set[CanRevokeRule])
42
40
  )
41
+ else
42
+ initialize_by_file_path(T.cast(params[:path], String))
43
43
  end
44
44
  end
45
45
 
@@ -11,13 +11,14 @@ class ArbacReachabilityVerifier
11
11
  sig { returns ArbacInstance }
12
12
  attr_reader :instance
13
13
 
14
- sig { params(args: T.any(String, ArbacInstance)).void }
15
- def initialize(**args)
16
- if !(args[:instance].nil?)
17
- @instance = T.let(T.cast(args[:instance], ArbacInstance), ArbacInstance)
18
- else
19
- path = T.cast(args[:path], String)
14
+ sig { params(params: T.any(String, ArbacInstance)).void }
15
+ def initialize(**params)
16
+ if params[:instance].nil?
17
+ path = T.cast(params[:path], String)
20
18
  @instance = ArbacUtilsModule::forward_slicing(ArbacUtilsModule::backward_slicing(ArbacInstance.new(path: path)))
19
+ else
20
+ instance = T.cast(params[:instance], ArbacInstance)
21
+ @instance = instance
21
22
  end
22
23
  end
23
24
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- # typed: true
2
+ # typed: strict
3
3
  require 'sorbet-runtime'
4
4
 
5
5
  class CanAssignRule
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- # typed: true
2
+ # typed: strict
3
3
  require 'sorbet-runtime'
4
4
 
5
5
  class CanRevokeRule
@@ -1,3 +1,4 @@
1
+ # typed: strict
1
2
  # Public: Specific exception to throw when a certain computation time exceeds a predefined limit
2
3
  class ComputationTimedOutException < StandardError
3
4
  end
@@ -1,7 +1,6 @@
1
- # typed: true
1
+ # typed: strict
2
2
  require 'sorbet-runtime'
3
3
 
4
- # Collection of utilities to manipulate .arbac files (defining an ARBAC role reachability problem) to parse and eventually solve the problem
5
4
  module ArbacUtilsModule
6
5
  extend T::Sig
7
6
 
@@ -1 +1,2 @@
1
+ # typed: strict
1
2
  require 'arbac_verifier/classes/arbac_reachability_verifier'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arbac_verifier
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefano Sello
@@ -80,8 +80,75 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '3.12'
83
- description: A simple solutor for role reachability problem instances expressed in
84
- ARBAC format.
83
+ description: " ![logo.png](https://github.com/stefanosello/arbac_verifier/raw/main/logo.png)\n\n
84
+ \ [![codecov](https://codecov.io/github/stefanosello/arbac_verifier/branch/development/graph/badge.svg?token=VXWHKJUJR2)](https://codecov.io/github/stefanosello/arbac_verifier)\n
85
+ \ [![Ruby Gem](https://github.com/stefanosello/arbac_verifier/actions/workflows/gem-push.yml/badge.svg?branch=development)](https://github.com/stefanosello/arbac_verifier/actions/workflows/gem-push.yml)\n
86
+ \ [![Gem Version](https://badge.fury.io/rb/arbac_verifier.svg)](https://badge.fury.io/rb/arbac_verifier)\n
87
+ \ [![Open Source? Yes!](https://badgen.net/badge/Open%20Source%20%3F/Yes%21/blue?icon=github)](https://github.com/Naereen/badges/)\n
88
+ \ \n \n **ARBAC Verifier** is a Ruby gem designed to facilitate the modeling
89
+ and verification of Administrative Role-Based Access Control (ARBAC) policies. With
90
+ this tool, you can efficiently model ARBAC policies and perform verification tasks
91
+ to determine if a specific role (`Goal`) can be achieved starting from a given set
92
+ of states (user-to-role assignments).\n \n This gem is grounded in comprehensive
93
+ theoretical foundations, which you can explore in detail through the [official security
94
+ course slides](https://secgroup.dais.unive.it/wp-content/uploads/2020/04/arbac.pdf)
95
+ provided by [Ca' Foscari University](https://www.unive.it/pag/13526) of Venice.
96
+ \n \n ## Installation\n The `arbac_verifier` gem can be installed from
97
+ [rubygems.org](https://rubygems.org/gems/arbac_verifier) from command line: \n ```{bash}\n
98
+ \ gem install arbac_verifier\n ```\n or by adding the following line to
99
+ your `Gemfile` project:\n ```{ruby}\n gem 'arbac_verifier', '~> 1.0', '>=
100
+ 1.0.1'\n ```\n \n ## ARBAC definition file\n An ARBAC (Attribute-Based
101
+ Role-Based Access Control) policy definition comprises four key components:\n -
102
+ **Users**: A set of individuals who are part of the system under analysis.\n -
103
+ **Roles**: A set of roles that can be assigned to or removed from users.\n -
104
+ **Can-Assign Rules**: These rules specify which roles can be assigned to users.
105
+ Each rule includes:\n - The role that has the authority to make the assignment.\n
106
+ \ - The role to be assigned.\n - Positive preconditions: Specific roles
107
+ that the user must already possess to be eligible for the new role.\n - Negative
108
+ preconditions: Specific roles that the user must not possess to be eligible for
109
+ the new role.\n - **Can-Revoke Rules**: These rules specify which roles can be
110
+ revoked from users. Each rule includes:\n - The role that has the authority
111
+ to revoke.\n - The role to be revoked. \n \n This structure ensures that
112
+ role assignments and revocations are controlled and based on the current state of
113
+ the user's roles.\n In order to represent a policy based on this definition,
114
+ we can use `arbac` files, which should follow this format:\n ```\n Roles Teacher
115
+ Student TA ;\n Users stefano alice bob ;\n UA <stefano,Teacher> <alice,TA>
116
+ ;\n CR <Teacher,Student> <Teacher,TA> ;\n CA <Teacher,-Teacher&-TA,Student>
117
+ <Teacher,-Student,TA> <Teacher,TA&-Student,Teacher> ;\n Goal Student ;\n ```
118
+ \n - Each line starts with an *header* that explains which information will be
119
+ represented\n - `Roles` and `Users` are straight forward\n - `UA` are
120
+ initial User Assignments, i.e. user-role assignments, where each item is a pair
121
+ of `<user,role>`\n - `CR` are Can-Revoke rules, where each item is a pair of
122
+ `<revoker role, revokable role>`\n - `CA` are Can-Assign rules, where each
123
+ item is a tern of `<assigner role, <positive1&positive2&-negative1&-negative2>,
124
+ assignable role>`\n - `Goal` is not an ARBAC property: it is the target role
125
+ for which the reachability should be verified\n - Each line ends with a `;`\n
126
+ \ - Items of each line are space-separated\n \n ## Usage\n Once installed,
127
+ the gem can be used to manage different tasks related to arbac policies.\n ```{Ruby}\n
128
+ \ require 'arbac_verifier'\n require 'set\n \n # Create new Arbac instance
129
+ from .arbac file\n policy0 = ArbacInstance.new(path: 'policy0.arbac')\n \n
130
+ \ # Create new Arbac instance passing single attributes\n policy1 = ArbacInstance.new(\n
131
+ \ goal: :Student,\n roles: [:Teacher, :Student, :TA].to_set,\n users:
132
+ [\"stefano\", \"alice\", \"bob\"].to_set,\n user_to_role: [UserRole.new(\"stefano\",
133
+ :Teacher), UserRole.new(\"alice\", :TA)].to_set,\n can_assign_rules: [\n CanAssignRule.new(:Teacher,
134
+ [].to_set, [:Teacher, :TA].to_set, :Student),\n CanAssignRule.new(:Teacher,
135
+ [].to_set, [:Student].to_set, :TA),\n CanAssignRule.new(:Teacher,
136
+ [:TA].to_set, [:Student].to_set, :Teacher)\n ].to_set,\n
137
+ \ can_revoke_rules: [CanRevokeRule.new(:Teacher, :Student), CanRevokeRule.new(:Teacher,
138
+ :TA)].to_set\n )\n ```\n \n Once the problem instance has been defined,
139
+ the gem provides two simplification algorithms that can be used to reduce the size
140
+ of the reachability problem.\n These algorithms do not modify the original policy
141
+ and return a new simplified policy.\n ```{Ruby}\n require 'arbac_verifier'\n
142
+ \ \n # apply backward slicing\n policy0bs = ArbacUtilsModule::backward_slicing(policy0)\n
143
+ \ policy0fs = ArbacUtilsModule::forward_slicing(policy0)\n ```\n A Role
144
+ Reachability Problem solution can be computed using the `ArbacReachabilityVerifier`
145
+ class.\n ```{Ruby}\n require 'arbac_verifier'\n \n # Creare new reachability
146
+ verifier instance starting from an .arbac file\n verifier0 = ArbacReachabilityVerifier.new(path:
147
+ 'policy0.arbac')\n \n # or from an already created ArbacInstance\n verifier1
148
+ = ArbacReachabilityVerifier.new(instance: policy1)\n \n # and then compute
149
+ reachability\n verifier0.verify # => true\n ```\n **NB:** when a verifier
150
+ instance is created starting from an `.arbac` file, backward and forward slicing
151
+ are applied to the parsed policy.\n"
85
152
  email: sellostefano@gmail.com
86
153
  executables: []
87
154
  extensions: []