
Security News
CISA’s 2025 SBOM Guidance Adds Hashes, Licenses, Tool Metadata, and Context
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.
Controlist support Ruby 1.9 and 2.x, ActiveRecord 3.2 and 4.1+
Add this line to your application's Gemfile:
gem 'controlist'
And then execute:
$ bundle
Or install it yourself as:
$ gem install controlist
require 'controlist'
require 'controlist/managers/thread_based_manager'
Controlist.initialize Controlist::Managers::ThreadBasedManager
You can use your customized manager or configuration to initialize Controlist
require 'controlist'
Controlist.initialize YourManager #logger: Logger.new(STDOUT)
# For read
Controlist.permission_manager.set_permission_package(OrderedPackage.new(
Controlist::Permission.new(User, READ, true, [
SimpleConstrain.new("name", "Tom"),
AdvancedConstrain.new(property: "name", value: ["Grade 1", "Grade 2"], relation: "clazz"),
AdvancedConstrain.new(property: "age", value: 5, operator: ">="),
SimpleConstrain.new("age", "null"),
SimpleConstrain.new("age", [1,2,3]),
SimpleConstrain.new("clazz_id", -> { Clazz.select(:id).map(&:id) }),
AdvancedConstrain.new(clause: "age != 100"),
AdvancedConstrain.new(proc_read: lambda{|relation| relation.order("id DESC").limit(3) })
])))
relation = User.unscoped
sql = relation.to_sql
assert_equal true, sql.include?("((users.name = 'Tom') and (clazzs.name in ('Grade 1','Grade 2')) and (users.age >= 5) and (users.age is null) and (users.age in (1,2,3)) and (users.clazz_id in (1,2,3)) and (age != 100)) ORDER BY id DESC LIMIT 3")
# For persistence
...
Controlist::Permission.new(User, UPDATE, false, AdvancedConstrain.new(property: "name", value: "To", operator: "include?")),
Controlist::Permission.new(User, UPDATE, false, AdvancedConstrain.new(proc_persistence: lambda{|object, operation| object.name == "Block"})),
Controlist::Permission.new(User, [UPDATE, DELETE], false, AdvancedConstrain.new(property: "name", value: ["Grade 1", "Grade 3"], relation: "clazz")),
...
# For apply attribute
...
Controlist::Permission.new(User, READ).apply(:name)
Controlist::Permission.new(User, UPDATE, true, SimpleConstrain.new("name", "Tom")).apply(name: "Test", clazz_id: [1, 2]),
# For skip
...
Controlist.skip do
relation = User.unscoped
sql = relation.to_sql
assert_equal "SELECT \"users\".* FROM \"users\"", sql.strip
end
...
# For modification on the fly
package = Controlist.permission_manager.get_permission_package
package.remove_permissions package.permissions.last
package.add_permissions Controlist::Permission.new(User, READ)
And more examples, please see more examples
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)Controlist is released under the MIT License.
FAQs
Unknown package
We found that controlist demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.
Security News
A clarification on our recent research investigating 60 malicious Ruby gems.
Security News
ESLint now supports parallel linting with a new --concurrency flag, delivering major speed gains and closing a 10-year-old feature request.