-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathharness.sh
More file actions
108 lines (90 loc) · 2.73 KB
/
Copy pathharness.sh
File metadata and controls
108 lines (90 loc) · 2.73 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/bin/bash
# Function to display usage information
usage() {
echo "Usage: $0 -s SOURCE_FILE_JS -e EXTRACTED_FILE_JS -k GROQ_API_KEY -v VERIFIED_FILE_JS"
echo ""
echo " -s SOURCE_FILE_JS Path to the source JavaScript file"
echo " -e EXTRACTED_FILE_JS Path to the extracted JavaScript file"
echo " -v VERIFIED_FILE_JS Path to the verified JavaScript file"
exit 1
}
# Parse command-line arguments
while getopts "s:e:k:v:" opt; do
case $opt in
s) SOURCE_FILE_JS=$OPTARG ;;
e) EXTRACTED_FILE_JS=$OPTARG ;;
v) VERIFIED_FILE_JS=$OPTARG ;;
*) usage ;;
esac
done
# Ensure all required arguments are provided
if [[ -z "$SOURCE_FILE_JS" || -z "$EXTRACTED_FILE_JS" || -z "$VERIFIED_FILE_JS" ]]; then
usage
fi
rm "$EXTRACTED_FILE_JS"
rm "$VERIFIED_FILE_JS"
touch "$EXTRACTED_FILE_JS"
touch "$VERIFIED_FILE_JS"
#=========================================#
# Phase 1
#=========================================#
echo "Running iife.js script..."
node src/js/iife.js "$SOURCE_FILE_JS" "$VERIFIED_FILE_JS"
if [[ $? -ne 0 ]]; then
echo "Error: iife.js script execution failed."
exit 1
fi
echo "Running filter.js script..."
node src/js/filter.js "$SOURCE_FILE_JS" "$VERIFIED_FILE_JS"
if [[ $? -ne 0 ]]; then
echo "Error: filter.js script execution failed."
exit 1
fi
echo "Running mrv.js script..."
node src/js/mrv.js "$SOURCE_FILE_JS" "$VERIFIED_FILE_JS"
if [[ $? -ne 0 ]]; then
echo "Error: mrv.js script execution failed."
exit 1
fi
# Renaming the exported function
echo "Running Python renaming script..."
python3 src/rename.py "$VERIFIED_FILE_JS" "PLACEHOLDER"
if [[ $? -ne 0 ]]; then
echo "Error: Python rename script execution failed."
exit 1
fi
# Calculating the Hex Values
echo "Running Python hex value script..."
python3 src/counter.py "$VERIFIED_FILE_JS"
if [[ $? -ne 0 ]]; then
echo "Error: Python counter script execution failed."
exit 1
fi
#
echo "Running Python integrator script..."
python3 src/integrator.py "$VERIFIED_FILE_JS"
if [[ $? -ne 0 ]]; then
echo "Error: Python integrator script execution failed."
exit 1
fi
cp "$SOURCE_FILE_JS" "$EXTRACTED_FILE_JS"
#=========================================#
# Phase 3
#=========================================#
# Resolving all variable names
echo "Resolving all variable names"
node $VERIFIED_FILE_JS "$EXTRACTED_FILE_JS"
if [[ $? -ne 0 ]]; then
echo "Error: verified.js script execution failed."
exit 1
fi
# Cleaning extracted.js
echo "Cleaning extracted.js"
node src/js/clean.js $EXTRACTED_FILE_JS $VERIFIED_FILE_JS
if [[ $? -ne 0 ]]; then
echo "Error: clean.js script execution failed."
exit 1
fi
rm $EXTRACTED_FILE_JS
rm $VERIFIED_FILE_JS
echo "Processing completed successfully."