SPB Git

Repository Public

remote.sh 3.6 KB 81 lines shellscript

1#!/usr/bin/env bash2# =============================================================================3#                  SP BOUCHER | SOFTWARE & RESEARCH4#             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5# =============================================================================6#7# Project          : QYVORA8# File             : security/audit/mobsf/remote.sh9# Module           : Security10# Repository       : https://git.spboucher.ai/qyvora11# Project Website  : Not specified12# Created          : 2026-12-0413# Last Modified    : 2026-12-0414#15# Author           : Simon-Pierre Boucher16# Position         : Professor of Finance17# Institution      : Université du Québec en Outaouais (UQO)18# Organization     : SP Boucher19# Website          : https://spboucher.ai20# Git              : https://git.spboucher.ai21#22# Preferred Contact: contact@spboucher.ai23# Development      : dev@spboucher.ai24# Support          : support@spboucher.ai25# Security/Admin   : admin@spboucher.ai26#27# Copyright (c) 202628# Simon-Pierre Boucher29# All rights reserved where applicable. This file is governed by the30# applicable project license, copyright notices and relevant law.31# Existing third-party rights and notices remain unaffected.32#33# License          : None specified (no license file in this repository)34#35# Do not embed credentials, private keys, access tokens,36# certificates or confidential personal information.37#38# =============================================================================39# END OF SP BOUCHER SOURCE HEADER40# =============================================================================4142# Manual control of the self-hosted MobSF container used by security/audit/runners/mobsf.py.43# The runner starts and removes the container by itself; this script is for inspection and for44# cleaning up after an interrupted run.45#46#   security/audit/mobsf/remote.sh status        container, image and leftover upload directories47#   security/audit/mobsf/remote.sh cleanup       remove the container (with volumes) and /tmp/qyvora-mobsf.*48#   security/audit/mobsf/remote.sh purge-image   cleanup + remove the pinned image (2.5 GB, re-pulled at the next run)49#50# Host, mode and image come from security/policies/mobsf.json.51set -euo pipefail52cd "$(dirname "$0")/../../.."53policy=security/policies/mobsf.json54read_key() { python3 -c "import json,sys; print(json.load(open('$policy'))[sys.argv[1]])" "$1"; }55mode=$(read_key mode); host=$(read_key host); name=$(read_key container)56image="$(read_key image)@$(read_key digest)"5758remote() {59  if [[ "$mode" == ssh ]]; then ssh -o BatchMode=yes -o ConnectTimeout=15 "$host" "$1"; else sh -c "$1"; fi60}6162case "${1:-status}" in63  status)64    echo "mode: $mode  host: $host  container: $name"65    remote "docker ps -a --filter name=^${name}\$ --format 'container: {{.Names}} {{.Status}} network={{.Networks}}'; \66            docker image inspect '$image' --format 'image: {{index .RepoDigests 0}} ({{.Size}} bytes)' 2>/dev/null || echo 'image: not present'; \67            ls -d /tmp/qyvora-mobsf.* 2>/dev/null || echo 'upload directories: none'"68    ;;69  cleanup)70    remote "docker rm -f -v '$name' >/dev/null 2>&1 || true; rm -rf /tmp/qyvora-mobsf.*; \71            docker ps -a --filter name=^${name}\$ --format '{{.Names}}' | grep -q . && echo 'container still present' || echo 'container removed'; \72            ls -d /tmp/qyvora-mobsf.* 2>/dev/null || echo 'upload directories removed'"73    ;;74  purge-image)75    "$0" cleanup76    remote "docker rmi '$image' >/dev/null 2>&1 && echo 'image removed' || echo 'image not present'"77    ;;78  *)79    echo "usage: $0 status|cleanup|purge-image" >&2; exit 2 ;;80esac81
Files main
Menu

Theme