Skip to content

Instantly share code, notes, and snippets.

View benjohnson's full-sized avatar

Ben Johnson benjohnson

View GitHub Profile
@cerebrl
cerebrl / 1-securing-express.md
Last active October 7, 2024 23:16
Securing ExpressJS

tl;dr

  1. Don't run as root.
  2. For sessions, set httpOnly (and secure to true if running over SSL) when setting cookies.
  3. Use the Helmet for secure headers: https://github.com/evilpacket/helmet
  4. Enable csrf for preventing Cross-Site Request Forgery: http://expressjs.com/api.html#csrf
  5. Don't use the deprecated bodyParser() and only use multipart explicitly. To avoid multiparts vulnerability to 'temp file' bloat, use the defer property and pipe() the multipart upload stream to the intended destination.
.book {
display: inline-block;
margin: 10px;
}
.book img {
vertical-align: middle;
}
.books {
@n1k0
n1k0 / Makefile
Last active December 14, 2015 11:58
A simple Makefile to run CasperJS tests for some Django project. Because sometimes, it doesn't have to be complicated.
casper:
make killserver
python manage.py runserver 9999 &
sleep 1
-casperjs test tests/casper/
make killserver
killserver:
ps aux|grep "python manage.py runserver 9999"|grep -v grep|awk '{print $$2}'|xargs kill
@skyl
skyl / kwacros.py
Created February 1, 2012 05:03
Django Template macros with args and kwargs
#
# templatetags/kwacros.py - Support for macros in Django templates
#
# Based on snippet by
# Author: Michal Ludvig <[email protected]>
# http://www.logix.cz/michal
#
# modified for args and kwargs by Skylar Saveland http://skyl.org
#
@cjohansen
cjohansen / gist:739589
Created December 13, 2010 20:55
Showing how to fake server requests with Sinon.JS and Jasmine
/*
Load Sinon.JS in the SpecRunner:
<script type="text/javascript" src="lib/jasmine-1.0.1/jasmine.js"></script>
<script type="text/javascript" src="lib/jasmine-1.0.1/jasmine-html.js"></script>
<script type="text/javascript" src="sinon-1.0.0.js"></script>
<script type="text/javascript" src="sinon-ie-1.0.0.js"></script>
http://cjohansen.no/sinon/
*/