forked from PinSpace-Org/GistPin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathassess-patches.sh
More file actions
executable file
路62 lines (53 loc) 路 2.55 KB
/
Copy pathassess-patches.sh
File metadata and controls
executable file
路62 lines (53 loc) 路 2.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env bash
set -euo pipefail
AWS_REGION="${AWS_REGION:-us-east-1}"
ENVIRONMENT="${ENVIRONMENT:-staging}"
REPORT_FILE="/tmp/patch-assessment-$(date +%Y%m%d).txt"
log() { echo "[$(date +%H:%M:%S)] $*" | tee -a "${REPORT_FILE}"; }
log "=== GistPin Patch Assessment ==="
log "Region: ${AWS_REGION} | Environment: ${ENVIRONMENT}"
# EC2 / EKS node patch compliance via SSM
log "[1/4] EC2 node patch compliance (SSM)"
aws ssm describe-instance-patch-states-for-patch-group \
--patch-group "gistpin-${ENVIRONMENT}" \
--region "${AWS_REGION}" \
--query 'InstancePatchStates[].[InstanceId,MissingCount,InstalledCount,FailedCount,LastNoRebootInstallOperationTime]' \
--output table 2>/dev/null | tee -a "${REPORT_FILE}" \
|| log "SSM patch data unavailable (no instances in patch group or SSM not configured)"
# Container image CVE scan via ECR
log "[2/4] ECR image vulnerability scan results"
for REPO in gistpin-backend gistpin-frontend; do
log " Repository: ${REPO}"
LATEST_TAG=$(aws ecr describe-images \
--repository-name "${REPO}" \
--region "${AWS_REGION}" \
--query 'sort_by(imageDetails, &imagePushedAt)[-1].imageTags[0]' \
--output text 2>/dev/null || echo "N/A")
if [[ "${LATEST_TAG}" != "N/A" ]]; then
aws ecr describe-image-scan-findings \
--repository-name "${REPO}" \
--image-id imageTag="${LATEST_TAG}" \
--region "${AWS_REGION}" \
--query 'imageScanFindings.findingSeverityCounts' \
--output table 2>/dev/null | tee -a "${REPORT_FILE}" || true
else
log " No images found in ${REPO}"
fi
done
# RDS engine version check
log "[3/4] RDS engine version and pending maintenance"
aws rds describe-db-instances \
--region "${AWS_REGION}" \
--query 'DBInstances[?contains(DBInstanceIdentifier, `gistpin`)].[DBInstanceIdentifier,EngineVersion,PendingModifiedValues.EngineVersion,AutoMinorVersionUpgrade]' \
--output table 2>/dev/null | tee -a "${REPORT_FILE}" || true
aws rds describe-pending-maintenance-actions \
--region "${AWS_REGION}" \
--query 'PendingMaintenanceActions[].[ResourceIdentifier,PendingMaintenanceActionDetails[0].Action,PendingMaintenanceActionDetails[0].AutoAppliedAfterDate]' \
--output table 2>/dev/null | tee -a "${REPORT_FILE}" || true
# Node OS package check (if kubectl available)
log "[4/4] Kubernetes node OS info"
kubectl get nodes -o wide 2>/dev/null | tee -a "${REPORT_FILE}" \
|| log "kubectl not available, skipping node OS info"
log ""
log "Assessment complete. Report: ${REPORT_FILE}"
log "Review CRITICAL/HIGH CVEs and missing patches before running patch-system.sh"