Skip to content

Instantly share code, notes, and snippets.

@foospidy
foospidy / example_redis_api_request.php
Created May 2, 2018
Example function for incrementing a counter based on the key of $id in Redis.
View example_redis_api_request.php
<?php
function api_request($id='nobody') {
$redis = new Redis();
if($redis->connect($GLOBALS['REDIS_HOST'], $GLOBALS['REDIS_PORT'])) {
if($redis->auth($GLOBALS['REDIS_PASSWORD'])) {
$redis->incr($id);
} else {
error_log('Error authenticating to redis!');
}
@foospidy
foospidy / sigsci_site_availability.py
Last active Feb 25, 2019
Script to generate aggregate availability based on data from Signal Sciences.
View sigsci_site_availability.py
#!/usr/bin/env python
"""
Script to generate aggregate availability based on data from Signal Sciences.
https://landing.google.com/sre/book/chapters/embracing-risk.html#risk-management_measuring-service-risk_aggregate-availability-equation
Usage:
./sigsci_site_availability.py -1d
Examples specifying different time periods:
./sigsci_site_availability.py -3d
View honeydb-search-payloads.py
#!/usr/bin/env python
"""
# HoneyDB helper script:
# honeydb-search-payloads.py
# For a given array of strings, this script will search payloads for a match.
# https://riskdiscovery.com/honeydb/threats#sensor_data_filtered
# Edit the SEARCH_STRINGS variable to specify what you want to search for.
# DATE is a required field for the API, and the default is today's date.
# Edit the DATE variable to search on a specific date.
# Requires:
@foospidy
foospidy / sigsci-copy-users.sh
Last active Feb 25, 2019
Copy all users from a site to other sites.
View sigsci-copy-users.sh
#!/usr/bin/env bash
###################
# Signal Sciences helper script:
# sigsci-copy-users.sh
# For a given site, copy all users to specified sites.
# Requires:
# - pysigsci (https://pypi.org/project/pysigsci/)
# - jq (https://stedolan.github.io/jq/)
# short name of site that has users you want to copy
@foospidy
foospidy / sigsci-copy-request-rule.sh
Last active Feb 25, 2019
Copy a rule to all sites in Signal Sciences
View sigsci-copy-request-rule.sh
#!/usr/bin/env bash
###################
# Signal Sciences helper script:
# sigsci-copy-request-rule.sh
# For a given site and rule id, the script will the rule to all sites.
# Requires:
# - pysigsci (https://pypi.org/project/pysigsci/)
# - jq (https://stedolan.github.io/jq/)
if [ -z $1 ];
@foospidy
foospidy / sigsci-copy-custom-signal.sh
Last active Feb 25, 2019
Copy a signal to all sites in Signal Sciences
View sigsci-copy-custom-signal.sh
#!/usr/bin/env bash
###################
# Signal Sciences helper script:
# sigsci-copy-custom-siganl.sh
# For a given site and tagName, the script will copy that signal to all sites.
# Requires:
# - pysigsci (https://pypi.org/project/pysigsci/)
# - jq (https://stedolan.github.io/jq/)
if [ -z $1 ];
@foospidy
foospidy / sigsci-integration-replace.sh
Last active Feb 25, 2019
Update/replace integration configuration in Signal Sciences
View sigsci-integration-replace.sh
#!/usr/bin/env bash
###################
# Signal Sciences helper script:
# sigsci-integration-replace.sh
# For a given configuration, the script will delete all instances based on type and url,
# it will then recreate the configuration with the specified events.
# Requires:
# - pysigsci (https://pypi.org/project/pysigsci/)
# - jq (https://stedolan.github.io/jq/)
@foospidy
foospidy / sigsci-expire-all-events.sh
Last active Feb 25, 2019
Expire all flagged IP events in Signal Sciences.
View sigsci-expire-all-events.sh
#!/usr/bin/env bash
###################
# Signal Sciences helper script:
# sigsci-expire-all-events.sh
# For a given site, the script will expire all flagged ip events.
# Requires:
# - pysigsci (https://pypi.org/project/pysigsci/)
# - jq (https://stedolan.github.io/jq/)
if [ -z $1 ];
@foospidy
foospidy / example_redis_reset_request_count.php
Last active Feb 25, 2019
Example script to reset the value to 0 for all keys in Redis.
View example_redis_reset_request_count.php
<?php
if($redis->connect($GLOBALS['REDIS_HOST'], $GLOBALS['REDIS_PORT'])) {
if($redis->auth($GLOBALS['REDIS_PASSWORD'])) {
$keys = $redis->keys('*');
foreach($keys as $key) {
$redis->set($key, 0);
}
} else {
error_log('Error authenticating to redis!');
@foospidy
foospidy / example_redis_api_limit_exceeded.php
Created May 2, 2018
Example function for checking the count value based on the key of $id in Redis against the value of $limit.
View example_redis_api_limit_exceeded.php
<?php
function api_limit_exceeded($id='nobody', $limit=1500) {
$redis = new Redis();
$usage = 0;
if($redis->connect($GLOBALS['REDIS_HOST'], $GLOBALS['REDIS_PORT'])) {
if($redis->auth($GLOBALS['REDIS_PASSWORD'])) {
$usage = $redis->get($id);
} else {
error_log('Error authenticating to redis!');