SPB Git

Repository Public License

check.sh 2.8 KB 56 lines shellscript

1#!/usr/bin/env bash2# =============================================================================3#                  SP BOUCHER | INFRASTRUCTURE & AUTOMATION4#             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5# =============================================================================6#7# Project          : ORIX Monitor8# File             : Scripts/check.sh9# Description      : Repository hygiene: author headers on every first-party10#                    source file and a scan of tracked files for secrets.11# Module           : Scripts12# Repository       : https://git.spboucher.ai/orix-monitor13# Created          : 2026-11-2114# Last Modified    : 2026-11-2115#16# Author           : Simon-Pierre Boucher17# Position         : Professor of Finance18# Institution      : Université du Québec en Outaouais (UQO)19# Organization     : SP Boucher20# Website          : https://spboucher.ai21# Git              : https://git.spboucher.ai22#23# Preferred Contact: support@spboucher.ai24# Technical Contact: dev@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          : Proprietary, all rights reserved (see license file)34# License File     : LICENSE35#36# Do not embed credentials, private keys, access tokens,37# certificates or confidential personal information.38#39# =============================================================================40# END OF SP BOUCHER SOURCE HEADER41# =============================================================================4243set -uo pipefail44cd "$(dirname "$0")/.."45STATUS=046while IFS= read -r file; do47  head -12 "$file" | grep -q "Author: Simon-Pierre Boucher" || { echo "missing header: $file"; STATUS=1; }48done < <(git ls-files -co --exclude-standard | grep -E '\.(swift|sh|py|yml)$|^\.gitignore$')49PATTERN='(-----BEGIN [A-Z ]*PRIVATE KEY-----|AKIA[0-9A-Z]{16}|xox[baprs]-[0-9A-Za-z-]{10,}|sk-[A-Za-z0-9_-]{24,}|ghp_[A-Za-z0-9]{30,}|(password|passwd|secret|api[_-]?key|token)["'"'"' ]*[:=]["'"'"' ]*[A-Za-z0-9/+_-]{12,})'50HITS="$(git ls-files -co --exclude-standard | grep -v -E '\.(png|icns|pdf|xcstrings)$|^Scripts/check\.sh$|translations-fr-CA\.json$' | xargs grep -I -n -i -E "$PATTERN" 2>/dev/null || true)"51if [[ -n "$HITS" ]]; then echo "possible secrets:"; echo "$HITS" | cut -c1-160; STATUS=1; fi52FORBIDDEN="$(git ls-files -co --exclude-standard | grep -E '\.(p12|p8|cer|mobileprovision|keychain|sqlite)$|(^|/)\.env' || true)"53if [[ -n "$FORBIDDEN" ]]; then echo "files that must not be committed:"; echo "$FORBIDDEN"; STATUS=1; fi54[[ $STATUS -eq 0 ]] && echo "OK: headers present, no secret found in $(git ls-files -co --exclude-standard | wc -l | tr -d ' ') files."55exit $STATUS56
Files main
Menu

Theme