Skip to content

Instantly share code, notes, and snippets.

View BobbyMcWho's full-sized avatar
🙃

Bobby McDonald BobbyMcWho

🙃
View GitHub Profile
@BobbyMcWho
BobbyMcWho / somewhere_in_update_script.rb
Last active April 8, 2021 18:08
Some code to create `Dependabot::SecurityAdvisory`s for use in dependabot-core scripts
# See: https://github.com/dependabot/dependabot-script/blob/master/update-script.rb
# Other update script logic
vulnerabilities = VulnerabilityFetcher.new(dependency_names, package_manager).fetch_advisories
# Note you may not just want top level depending on your use case
dependencies.select(&:top_level?).each do |dep|
security_vulnerabilities = []
if vulnerabilities.any?
security_vulnerabilities = vulnerabilities[dep.name.to_sym].map do |vuln|
@BobbyMcWho
BobbyMcWho / ruby-debug.md
Last active September 27, 2019 21:26
Debugging Ruby locally in VSCode using ruby-debug and native breakpoints

In the extensions marketplace, search "ruby-debug" and install globally. You may need to reload your workspace afterwards.

You'll need to add readapt to your project's gemfile and bundle install.

group :development do 
  # gems...
  gem 'readapt' # Debugging with vscode ruby-debug extension
@BobbyMcWho
BobbyMcWho / _libxml2_error.md
Last active September 12, 2018 04:52
libxml2 bug when validating against a complexType in an XSD

I came across this error when validating XML files against an XSD in Nokogiri.

When validating a complexType XML element, if a node fails validation due to a Occurence restriction, and it is the last node in the complex element, the validation error will not raise, and will pass as a valid document. If there is another node in the sequence that is allowed, then at that point the document will fail validation. However, the error that is thrown is misleading, because it will say that the second element is the one that is out of place, rather than the one that is actually out of place.

The easiest way to reproduce this is with xmllint:

$xmllint --noout --schema example_xsd.xsd incorrectly_passing.xml
incorrectly_passing.xml validates

Keybase proof

I hereby claim:

  • I am bobbymcwho on github.
  • I am bobbymcwho (https://keybase.io/bobbymcwho) on keybase.
  • I have a public key ASBLy5Vbk00319-ZDn5u38bHLlTnhYEBFKH-NQzq5Zd4Xwo

To claim this, I am signing this object: