
Security News
Risky Biz Podcast: Making Reachability Analysis Work in Real-World Codebases
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
= Ruby Jing
{}[https://github.com/sshaw/ruby-jing/actions/workflows/rake.yml]
{
}[https://codeclimate.com/github/sshaw/ruby-jing]
RELAX NG schema validation using the {Jing CLI}[http://www.thaiopensource.com/relaxng/jing.html]
=== Overview
require "jing"
jing = Jing.new("schema.rng") begin errors = jing.validate("doc.xml") rescue Jing::Error => e abort "what what what #{e}" end
if errors.none? puts "Valid!" else errors.each do |error| puts "#{error[:message]} @ #{error[:line]}:#{error[:column]}" end end
abort "Invalid!" unless jing.valid?("/path/to/doc.xml")
=== Why use Java to validate instead of Ruby libraries like Nokorigi, REXML, libxml, etc..?
Simple: good error messages. Let's look at the error messages provided by each of these libraries.
v1 v2 John Smith Doh!==== Nokorigi/libxml
schema = Nokogiri::XML::RelaxNG(File.read(rng)) doc = Nokogiri::XML(File.read(xml)) errors = schema.validate(doc) errors.each { |e| puts e }
Resulting errors:
Element card failed to validate attributes Expecting an element , got nothing
Element card failed to validate attributes Did not expect element oops there
==== REXML
include REXML doc = Document.new(File.read(xml)) validator = Validation::RelaxNG.new(File.read(rng)) validator.validate(doc)
Fails for XML A and XML B --it treats the XML declaration as a validation error!
Validation error. Expected: :start_element( addressBook ) from < S.1 #:start_element( addressBook ), < Z.2 #:start_element( card ), :start_attribute( version ), < C.3 :text( v1 ) or :text( v2 ) >, :end_attribute( ), :start_element( name ), :text( ), :end_element( ), :start_element( email ), :text( ), :end_element( ), :end_element( ) >, :end_element( ), :end_document( ) > but got ( )
==== Jing
jing = Jing.new(schema) errors = jing.validate(xml) errors.each { |e| puts e[:message] }
Resulting errors:
element "card" missing required attribute "version" element "card" incomplete; missing required element "name"
value of attribute "version" is invalid; must be equal to "v1" or "v2" element "oops" not allowed anywhere; expected the element end-tag
Better, don't ya think?
=== More Info
=== Author
Skye Shaw [skye.shaw AT gmail.com]
=== License
Released under the MIT License: www.opensource.org/licenses/MIT
=== Jing Copying Conditions
Copyright (c) 2001-2003 Thai Open Source Software Center Ltd All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
FAQs
Unknown package
We found that ruby-jing 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
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.