
Security News
Follow-up and Clarification on Recent Malicious Ruby Gems Campaign
A clarification on our recent research investigating 60 malicious Ruby gems.
A comprehensive Ruby client library for the ResourceSpace open-source Digital Asset Management system. This gem provides an easy-to-use interface for managing web assets including images, CSS files, JavaScript files, fonts, and other digital resources.
Add this line to your application's Gemfile:
gem 'resourcespace-ruby'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install resourcespace-ruby
require 'resourcespace'
# Configure globally
ResourceSpace.configure do |config|
config.url = "https://your-resourcespace.com/api/"
config.user = "your_username"
config.private_key = "your_private_key" # Get this from your ResourceSpace profile
config.timeout = 30
end
# Or configure per instance
client = ResourceSpace::Client.new(
url: "https://your-resourcespace.com/api/",
user: "your_username",
private_key: "your_private_key"
)
# Test connection
status = client.test_connection
puts "Connected to ResourceSpace #{status['version']}"
# Search for web assets
results = client.search.search_web_assets("images")
puts "Found #{results.length} image assets"
# Upload a web asset
uploaded = client.resources.upload_file(
File.open("assets/logo.png"),
caption: "Company Logo"
)
# Create a collection for web assets
collection = client.collections.create_web_asset_collection(
"Website Assets",
asset_type: "images"
)
# Add resource to collection
client.collections.add_resource_to_collection(uploaded['ref'], collection['ref'])
This gem is specifically designed to work well with web development assets:
# Upload different types of web assets
logo = client.resources.upload_file("assets/logo.png")
stylesheet = client.resources.upload_file("assets/main.css")
script = client.resources.upload_file("assets/app.js")
font = client.resources.upload_file("assets/custom-font.woff2")
# Search by asset type
images = client.search.search_web_assets("images")
css_files = client.search.search_web_assets("css")
js_files = client.search.search_web_assets("javascript")
fonts = client.search.search_web_assets("fonts")
# Search by file extension
svg_files = client.search.search_by_extension(["svg"])
web_fonts = client.search.search_by_extension(["woff", "woff2", "ttf"])
# Create collections for different asset types
image_collection = client.collections.create_web_asset_collection(
"Website Images",
asset_type: "images"
)
css_collection = client.collections.create_web_asset_collection(
"Stylesheets",
asset_type: "css"
)
# Get all web asset collections
web_collections = client.collections.get_web_asset_collections
# Set up web asset metadata fields (one-time setup)
client.metadata.create_web_asset_fields
# Update resource with web asset metadata
client.metadata.update_web_asset_metadata(resource_id, {
title: "Hero Background Image",
asset_type: "Image",
dimensions: "1920x1080",
usage_rights: "Creative Commons",
purpose: "Website header background"
})
# Create a new resource
resource = client.resources.create_resource(
name: "Company Logo",
resource_type: 1,
metadata: {
12 => "logo, branding, company", # Keywords field
51 => "Image" # Custom asset type field
}
)
# Get resource details
details = client.resources.get_resource_data(resource_id)
# Update resource metadata
client.resources.update_field(resource_id, 8, "New Title")
# Download resource
client.resources.download_resource(resource_id, "/local/path/file.jpg")
# Get alternative files
alternatives = client.resources.get_alternative_files(resource_id)
# Advanced search with multiple criteria
results = client.search.advanced_search({
title: "logo",
extensions: ["png", "svg"],
from_date: "2023-01-01",
to_date: "2023-12-31"
}, {
order_by: "date",
sort: "desc",
fetchrows: 20
})
# Search by date range
recent = client.search.search_by_date_range("2023-01-01", "2023-12-31")
# Get recently added resources
latest = client.search.recent_resources(10)
# Create collection
collection = client.collections.create_collection(
"Marketing Assets",
public: false,
allow_changes: true
)
# Add multiple resources
resource_ids = [123, 124, 125]
client.collections.add_resources_to_collection(resource_ids, collection_id)
# Search public collections
public_collections = client.collections.search_public_collections("web")
# Check user capabilities
capabilities = client.users.capabilities
puts "Can upload: #{capabilities[:upload]}"
puts "Can edit: #{capabilities[:edit_resources]}"
# Check specific permissions
can_download = client.users.can_download?
has_admin = client.users.admin?
# Check resource-specific permissions
can_edit_resource = client.users.can_edit_resource?(resource_id)
ResourceSpace.configure do |config|
config.url = "https://your-resourcespace.com/api/" # Required
config.user = "username" # Required
config.private_key = "your_private_key" # Required
config.timeout = 30 # Request timeout (seconds)
config.retries = 3 # Number of retry attempts
config.verify_ssl = true # Verify SSL certificates
config.auth_mode = "userkey" # Authentication mode
config.debug = false # Enable debug logging
config.logger = Logger.new(STDOUT) # Custom logger
end
The gem provides specific exception types for different error conditions:
begin
resource = client.resources.get_resource_data(999)
rescue ResourceSpace::NotFoundError => e
puts "Resource not found: #{e.message}"
rescue ResourceSpace::AuthenticationError => e
puts "Authentication failed: #{e.message}"
rescue ResourceSpace::AuthorizationError => e
puts "Access denied: #{e.message}"
rescue ResourceSpace::ValidationError => e
puts "Invalid data: #{e.message}"
rescue ResourceSpace::ServerError => e
puts "Server error: #{e.message}"
rescue ResourceSpace::NetworkError => e
puts "Network error: #{e.message}"
end
For Rails applications, add an initializer:
# config/initializers/resourcespace.rb
ResourceSpace.configure do |config|
config.url = ENV['RESOURCESPACE_URL']
config.user = ENV['RESOURCESPACE_USER']
config.private_key = ENV['RESOURCESPACE_PRIVATE_KEY']
config.timeout = 30
end
Then use in your application:
class AssetsController < ApplicationController
def upload
client = ResourceSpace::Client.new
uploaded = client.resources.upload_file(params[:file])
# Store reference in your model
@asset = Asset.create(
name: uploaded['title'],
resourcespace_id: uploaded['ref'],
file_type: uploaded['file_extension']
)
end
end
Run the test suite:
$ bundle exec rspec
Run tests with coverage:
$ COVERAGE=1 bundle exec rspec
After checking out the repo, run:
$ bin/setup
$ bundle exec rake spec
To install this gem onto your local machine:
$ bundle exec rake install
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)For complete API documentation, see the ResourceSpace API documentation.
The gem is available as open source under the terms of the MIT License.
FAQs
Unknown package
We found that resourcespace-ruby demonstrated a healthy version release cadence and project activity because the last version was released less than 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
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.
Research
/Security News
A malicious Go module posing as an SSH brute forcer exfiltrates stolen credentials to a Telegram bot controlled by a Russian-speaking threat actor.