Skip to content

Instantly share code, notes, and snippets.

View sbassett29's full-sized avatar

Scott B sbassett29

  • Chicago
View GitHub Profile
@sbassett29
sbassett29 / README.md
Last active June 28, 2024 20:54
Wikimedia Third-Party-Resoruces Search and Analysis

Wikimedia TPR Scanner

A python cli and some semgrep rules for scanning CSS and JS under the MediaWiki namespace for external resource usage.

Dependencies

  1. Python 3+
  2. Semgrep
  3. About 350 Mb of local disk space (to cache CSS and JS files)
@sbassett29
sbassett29 / install-mw-gadgets.sh
Created May 7, 2024 19:38
A basic mediawiki-docker/ext:gadgets install script
#!/usr/bin/env bash
################################################################################
# Author: [email protected]
# License: Apache 2 <https://opensource.org/licenses/Apache-2.0>
# Usage: chmod +x install-gadget-test-mw.sh && ./install-gadget-test-mw.sh
################################################################################
set -euo pipefail
# check binary dependencies
bins=("cat" "echo" "git" "docker")
@sbassett29
sbassett29 / ast.php
Created February 8, 2024 22:36
php cli ast generation
#!/usr/bin/env php
<?php
declare(strict_types=1);
define( "AST_PHP_VERSION", 80 );
if( PHP_SAPI !== 'cli' ) {
exit("Please run as a PHP CLI!");
}
#!/usr/bin/env bash
# based upon https://gist.github.com/mbohun/b161521b2440b9f08b59
# re: https://about.codecov.io/security-update/
DEBUG=false
GITHUB_API_BASE="https://api.github.com"
GITHUB_API_REST="/orgs/wikimedia/repos"
GITHUB_API_HEADER_ACCEPT="Accept: application/vnd.github.v3+json"
# set GITHUB_TOKEN
@sbassett29
sbassett29 / gen_wmf_git_users.py
Created July 5, 2023 14:19
Creates a list of likely wmf git author names and emails from ldap.toolforge.org
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# License: Apache 2.0
import csv
import requests
import time
from lxml import html
@sbassett29
sbassett29 / .Wikimedia Repo Counts
Last active November 26, 2024 19:24
Get all active Wikimedia repos
(see scripts)
@sbassett29
sbassett29 / foreachwikisql.sh
Last active January 25, 2023 00:42
Some bash to pull local wiki users in a certain group and check against centralauth - in this case, 2fa enablement
#!/usr/bin/env bash
################################################################################
# Author: [email protected]
# License: Apache 2 <https://opensource.org/licenses/Apache-2.0>
################################################################################
. /etc/profile.d/mediawiki.sh
# pass debug as an argument to use a smaller test dblist
if [[ "$1" != "debug" ]]; then
@sbassett29
sbassett29 / gerrit-search-count.sh
Created June 7, 2022 02:05
Returns (complete) count of rows from gerrit api searches (gerrit.website/r/changes/?q=some-search-string)
#!/usr/bin/env bash
################################################################################
# Author: [email protected]
# License: Apache 2 <https://opensource.org/licenses/Apache-2.0>
# Description:
# A way to get (complete) row counts for gerrit searches via its api
################################################################################
set -euo pipefail
# validate arguments
@sbassett29
sbassett29 / namely_api_ccess.py
Last active June 3, 2022 20:36
Some python to access Profiles from Namely's API
!/usr/bin/env python3
# -*- coding: utf-8 -*-
""" Search for people in a Namely API
Doc: https://developers.namely.com/docs/namely-api/
Author: sbassett29
License: CC0
"""
import json
@sbassett29
sbassett29 / service-repo-list.sh
Last active March 3, 2022 21:52
get mediawiki/services full list from gerrit api
#!/usr/bin/env bash
curl -s https://gerrit.wikimedia.org/r/projects/?r=mediawiki/services/.* | \
awk 'NR>1' | \
jq -r 'to_entries[] | "\(.key) [ \(.value.web_links[0].url) ]"'