Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
= collectiveaccess
This gem is a simple plain Ruby wrapper for the {CollectiveAccess}[http://www.collectiveaccess.org/] Web {Service API}[docs.collectiveaccess.org/wiki/Web_Service_API]. Before you start fiddling with the gem, make sure you're familiar with the API.
Note that this library requires CollectiveAccess Providence v1.5 or later! It might work with v1.4 but we don't test it against the old stable code.
== Setup
Through RubyGems:
gem install collectiveaccess
In a Gemfile:
gem 'collectiveaccess', '~> 0.2.0'
== Usage
The API consists of only class methods. We never save any state except for user credentials.
=== Authentication
You can pass the authentication credentials for your CollectiveAccess setup via environment variables, like so
$ export CA_SERVICE_API_USER='administrator'
$ export CA_SERVICE_API_KEY='dublincore'
$ irb
2.2.1 :001 > require 'collectiveaccess'
=> true
2.2.1 :002 > CollectiveAccess.get
In a Ruby on Rails app you could use the {dotenv}[https://github.com/bkeepers/dotenv] gem to accomplish the same. You can also set the credentials explicitly in your code:
$ irb
2.2.1 :001 > require 'collectiveaccess'
=> true
2.2.1 :002 > CollectiveAccess.set_credentials 'administrator', 'dublincore'
=> {:username=>"administrator", :password=>"dublincore"}
2.2.1 :003 > CollectiveAccess.get
The gem uses these credentials to authenticate with the {login service endpoint}[http://docs.collectiveaccess.org/wiki/Web_Service_API#Authentication] and obtain an authentication service token. It then saves this token, which is valid for about an hour by default, in a temporary file in the local file system so that it can restore the session on subsequent requests.
=== Queries
The CollectiveAccess class has static methods for all the HTTP request schemes the service API uses: get, post, put, delete, options. All these methods take a single options hash as parameter. Below is the default hash that gets merged with whatever you pass. All these keys are available.
DEFAULT_REQUEST_OPTS = {
protocol: 'http',
hostname: 'localhost',
url_root: '/',
script_name: 'service.php',
table_name: 'ca_objects',
endpoint: 'item',
request_body: {},
get_params: {},
url_string: ''
}
The methods return the parsed JSON response from the API as hash, or nil of something went wrong. Below are a few examples. All of them assume that you have required the 'collectiveaccess' gem and also that authentication is set up correctly (see above).
===== Get a generic summary for object with id 1 r = CollectiveAccess.get hostname: 'providence.dev', table_name: 'ca_objects', endpoint: 'item', url_string: '/id/1' puts "#{r}"
===== Get a specific bundle list for object with id 1 r = CollectiveAccess.get hostname: 'providence.dev', table_name: 'ca_objects', endpoint: 'item', url_string: '/id/1', request_body: { bundles: { 'ca_objects.idno' => {}, 'ca_objects.preferred_labels' => {}, 'ca_entities' => { :returnAsArray => true } } } puts "#{r}"
===== Search for * r = CollectiveAccess.get hostname: 'providence.dev', table_name: 'ca_objects', endpoint: 'find', get_params: { q: '*' } puts "#{r}"
===== Search for something more specific, and also specify what we want returned in the result r = CollectiveAccess.get hostname: 'providence.dev', table_name: 'ca_objects', endpoint: 'find', get_params: { q: 'Homer' }, request_body: { bundles: { 'ca_objects.idno' => {}, 'ca_objects.preferred_labels' => {}, 'ca_entities' => { :returnAsArray => true } } } puts "#{r}"
=== "Simple" API
In v1.6 of CollectiveAccess there's a new service interface called
{Simple API}[http://docs.collectiveaccess.org/wiki/SimpleAPI]. Gem versions v0.2.x and later support querying
this API using the simple
class method. Below is an example for the endpoint 'testDetail'. Note that you have
to define the endpoint first in your CollectiveAccess services configuration for this to work. For more info
take a look at the {documentation}[http://docs.collectiveaccess.org/wiki/SimpleAPI]:
r = CollectiveAccess.simple hostname: 'providence.dev', endpoint: 'testDetail', get_params: { id: 1 }
== Contributing to collectiveaccess
== Copyright
Copyright (c) 2015 Whirl-i-Gig. See LICENSE.txt for further details.
FAQs
Unknown package
We found that collectiveaccess demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.