livrare lot 2

This commit is contained in:
EVOTECH IT SRL 2026-07-10 03:39:53 -07:00
commit 8ecc78e729
763 changed files with 164593 additions and 0 deletions

View file

@ -0,0 +1,72 @@
#!/bin/bash
# Bulk insert all indicators from JSON file
# Usage: ./bulk_insert_indicators.sh
API_URL="http://localhost:3005/api/indicators/bulk-for-technique"
JSON_FILE="/home/adrian/didi_mono/backend/services/orchestration-layer/didiFramework/data/indicators_bulk.json"
# Get list of technique IDs that already have indicators
echo "Checking existing indicators..."
EXISTING=$(curl -s http://localhost:3005/api/indicators | jq -r '.data[].technique_id' | sort -u | tr '\n' ',' | sed 's/,$//')
echo "Techniques with existing indicators: $EXISTING"
# Get stats before
echo ""
echo "=== BEFORE ==="
curl -s http://localhost:3005/api/indicators/stats | jq '.data'
# Counter for progress
TOTAL=0
SUCCESS=0
FAILED=0
# Process each technique from JSON
echo ""
echo "=== INSERTING ==="
for technique_id in $(cat $JSON_FILE | jq -r '.indicators[].technique_id'); do
# Check if technique already has indicators
HAS_INDICATORS=$(curl -s "http://localhost:3005/api/indicators/by-technique/$technique_id" | jq -r '.count')
if [ "$HAS_INDICATORS" != "0" ] && [ "$HAS_INDICATORS" != "null" ]; then
echo "SKIP: Technique $technique_id already has $HAS_INDICATORS indicators"
continue
fi
# Get indicators for this technique from JSON
INDICATORS=$(cat $JSON_FILE | jq -c --arg tid "$technique_id" '.indicators[] | select(.technique_id == ($tid | tonumber)) | .indicators')
if [ -z "$INDICATORS" ] || [ "$INDICATORS" == "null" ]; then
echo "SKIP: No indicators found for technique $technique_id"
continue
fi
# Insert
RESULT=$(curl -s -X POST "$API_URL/$technique_id" \
-H "Content-Type: application/json" \
-d "{\"indicators\": $INDICATORS}")
IS_SUCCESS=$(echo $RESULT | jq -r '.success')
COUNT=$(echo $RESULT | jq -r '.count // 0')
if [ "$IS_SUCCESS" == "true" ]; then
echo "OK: Technique $technique_id - $COUNT indicators inserted"
SUCCESS=$((SUCCESS + 1))
TOTAL=$((TOTAL + COUNT))
else
ERROR=$(echo $RESULT | jq -r '.error')
echo "FAIL: Technique $technique_id - $ERROR"
FAILED=$((FAILED + 1))
fi
done
echo ""
echo "=== SUMMARY ==="
echo "Techniques processed: $((SUCCESS + FAILED))"
echo "Success: $SUCCESS"
echo "Failed: $FAILED"
echo "Total indicators inserted: $TOTAL"
echo ""
echo "=== AFTER ==="
curl -s http://localhost:3005/api/indicators/stats | jq '.data'

View file

@ -0,0 +1,62 @@
#!/bin/bash
# Bulk insert all validation rules from JSON file
API_URL="http://localhost:3005/api/validation-rules/bulk-for-technique"
JSON_FILE="/home/adrian/didi_mono/backend/services/orchestration-layer/didiFramework/data/validation_rules_bulk.json"
echo "=== BEFORE ==="
curl -s http://localhost:3005/api/validation-rules/stats | jq '.data'
TOTAL=0
SUCCESS=0
FAILED=0
echo ""
echo "=== INSERTING ==="
for technique_id in $(cat $JSON_FILE | jq -r '.validation_rules[].technique_id'); do
# Check if technique already has rules
HAS_RULES=$(curl -s "http://localhost:3005/api/validation-rules/by-technique/$technique_id" | jq -r '.count')
if [ "$HAS_RULES" != "0" ] && [ "$HAS_RULES" != "null" ]; then
echo "SKIP: Technique $technique_id already has $HAS_RULES rules"
continue
fi
# Get rules for this technique from JSON
RULES=$(cat $JSON_FILE | jq -c --arg tid "$technique_id" '.validation_rules[] | select(.technique_id == ($tid | tonumber)) | .rules')
if [ -z "$RULES" ] || [ "$RULES" == "null" ]; then
echo "SKIP: No rules found for technique $technique_id"
continue
fi
# Insert
RESULT=$(curl -s -X POST "$API_URL/$technique_id" \
-H "Content-Type: application/json" \
-d "{\"rules\": $RULES}")
IS_SUCCESS=$(echo $RESULT | jq -r '.success')
COUNT=$(echo $RESULT | jq -r '.count // 0')
if [ "$IS_SUCCESS" == "true" ]; then
echo "OK: Technique $technique_id - $COUNT rules inserted"
SUCCESS=$((SUCCESS + 1))
TOTAL=$((TOTAL + COUNT))
else
ERROR=$(echo $RESULT | jq -r '.error')
echo "FAIL: Technique $technique_id - $ERROR"
FAILED=$((FAILED + 1))
fi
done
echo ""
echo "=== SUMMARY ==="
echo "Techniques processed: $((SUCCESS + FAILED))"
echo "Success: $SUCCESS"
echo "Failed: $FAILED"
echo "Total rules inserted: $TOTAL"
echo ""
echo "=== AFTER ==="
curl -s http://localhost:3005/api/validation-rules/stats | jq '.data'