Skip to content

Instantly share code, notes, and snippets.

@Demuxx
Demuxx / gist:dee14ea650ff7900f2c0
Last active April 12, 2018 07:51
XXE Protections for DocumentBuilderFactory
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException; // catching unsupported features
...
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
try {
// Xerces 1 - http://xerces.apache.org/xerces-j/features.html#external-general-entities
// Xerces 2 - http://xerces.apache.org/xerces2-j/features.html#external-general-entities
dbf.setFeature("http://xml.org/sax/features/external-general-entities", false);
@Demuxx
Demuxx / gist:168a865969ade4d4f02b
Created July 18, 2014 07:07
Cron job for ruby on rails scripts
#!/usr/bin/env bash
# codex_update.sh
# load rvm ruby
source /Users/thegodfather/.rvm/environments/ruby-2.1.2
cd /Users/thegodfather/code/codex
bundle install
ruby ./bin/codex_update.rb
@Demuxx
Demuxx / gist:6744d50cd6a0fa05845c
Created July 2, 2014 23:44
Ruby password generator
#!/usr/bin/env ruby
o = [('a'..'z'), ('A'..'Z'), (0..9), ('!'..'$'), ('\''.."+")].map { |i| i.to_a }.flatten
if !ARGV[0].nil?
puts (0...ARGV[0].to_i).map{ o[rand(o.length)] }.join
else
puts (0...20).map{ o[rand(o.length)] }.join
end
gisttest = "gisttest"
@Demuxx
Demuxx / gist:5105647
Created March 7, 2013 04:53
failed to bundle install balancir on ruby 2.0.0-p0
michael@michael-VirtualBox:~/Documents/Dev/balancir/spec/lib/balancir$ bundle install
Fetching gem metadata from https://rubygems.org/.........
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
Installing awesome_print (1.1.0)
Installing facter (1.6.17)
Installing timers (1.1.0)
Installing celluloid (0.12.4)
Installing excon (0.19.5)
Using balancir (0.0.1) from source at /home/michael/Documents/Dev/balancir