-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpush-to-github.sh
More file actions
executable file
·282 lines (245 loc) · 6.89 KB
/
Copy pathpush-to-github.sh
File metadata and controls
executable file
·282 lines (245 loc) · 6.89 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
#!/bin/bash
# Safe script to push XFB to GitHub
# Checks for sensitive information before pushing
set -e
echo "=========================================="
echo "XFB GitHub Push Safety Check"
echo "=========================================="
echo ""
# Function to check for sensitive patterns
check_sensitive_info() {
local file=$1
local pattern=$2
local description=$3
if grep -q "$pattern" "$file" 2>/dev/null; then
echo "⚠️ Warning: Possible $description found in $file"
grep -n "$pattern" "$file" | head -5
return 1
fi
return 0
}
# Files and directories to exclude from push
EXCLUDE_PATTERNS=(
"*.key"
"*.pem"
"*.p12"
"*.pfx"
"*.jks"
"*.keystore"
".env"
".env.*"
"secrets.yml"
"credentials.json"
"*.log"
"*.sqlite"
"*.db"
"build/"
"tmp/"
"tmp_*/"
"*.pkg.tar.zst"
"src/"
"pkg/"
"debian-repo/"
"aur-xfb/"
)
echo "Step 1: Checking for sensitive information..."
echo ""
ISSUES_FOUND=0
# Check for actual passwords (not just the word "password")
echo "Checking for hardcoded credentials..."
if git grep -i "password\s*=\s*['\"][^'\"]*['\"]" -- '*.cpp' '*.h' '*.sh' 2>/dev/null | grep -v "Password:" | grep -v "password.*\[" | grep -v "//"; then
echo "⚠️ Warning: Possible hardcoded password found"
ISSUES_FOUND=1
fi
# Check for API keys
echo "Checking for API keys..."
if git grep -iE "(api[_-]?key|apikey)\s*=\s*['\"][^'\"]{20,}['\"]" 2>/dev/null; then
echo "⚠️ Warning: Possible API key found"
ISSUES_FOUND=1
fi
# Check for private keys
echo "Checking for private keys..."
if git grep -l "BEGIN.*PRIVATE KEY" 2>/dev/null; then
echo "⚠️ Warning: Private key found"
ISSUES_FOUND=1
fi
# Check for tokens
echo "Checking for tokens..."
if git grep -iE "token\s*=\s*['\"][^'\"]{20,}['\"]" 2>/dev/null | grep -v "GITHUB_TOKEN" | grep -v "secrets."; then
echo "⚠️ Warning: Possible token found"
ISSUES_FOUND=1
fi
# Check for real email addresses in code (not documentation)
echo "Checking for personal email addresses..."
if git grep -E "[a-zA-Z0-9._%+-]+@(?!example\.com|netpack\.pt|xfb\.com)[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}" -- '*.cpp' '*.h' 2>/dev/null; then
echo "⚠️ Warning: Personal email address found in code"
ISSUES_FOUND=1
fi
# Check .netrc for real credentials
if [ -f "config/.netrc" ]; then
echo "Checking .netrc file..."
if grep -v "\[" config/.netrc | grep -qE "password\s+[^[]"; then
echo "⚠️ Warning: Real credentials in .netrc file"
ISSUES_FOUND=1
else
echo "✓ .netrc contains only placeholders"
fi
fi
if [ $ISSUES_FOUND -eq 0 ]; then
echo "✓ No sensitive information detected"
else
echo ""
echo "❌ Potential sensitive information found!"
echo "Please review the warnings above before pushing."
echo ""
read -p "Continue anyway? (y/N) " -n 1 -r
echo ""
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "Push cancelled"
exit 1
fi
fi
echo ""
echo "Step 2: Checking .gitignore..."
echo ""
# Verify important patterns are in .gitignore
REQUIRED_IGNORES=(
"*.key"
"*.pem"
".env"
"*.log"
"build/"
"*.pkg.tar.zst"
)
MISSING_IGNORES=()
for pattern in "${REQUIRED_IGNORES[@]}"; do
if ! grep -q "^$pattern" .gitignore 2>/dev/null; then
MISSING_IGNORES+=("$pattern")
fi
done
if [ ${#MISSING_IGNORES[@]} -gt 0 ]; then
echo "⚠️ Warning: Some patterns missing from .gitignore:"
printf '%s\n' "${MISSING_IGNORES[@]}"
echo ""
read -p "Add them now? (y/N) " -n 1 -r
echo ""
if [[ $REPLY =~ ^[Yy]$ ]]; then
for pattern in "${MISSING_IGNORES[@]}"; do
echo "$pattern" >> .gitignore
done
echo "✓ Updated .gitignore"
fi
else
echo "✓ .gitignore looks good"
fi
echo ""
echo "Step 3: Checking Git status..."
echo ""
# Check if there are uncommitted changes
if ! git diff-index --quiet HEAD -- 2>/dev/null; then
echo "Uncommitted changes found:"
git status --short
echo ""
read -p "Commit these changes? (y/N) " -n 1 -r
echo ""
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo "Enter commit message:"
read -r COMMIT_MSG
git add .
git commit -m "$COMMIT_MSG"
echo "✓ Changes committed"
else
echo "Please commit or stash changes before pushing"
exit 1
fi
else
echo "✓ Working directory clean"
fi
echo ""
echo "Step 4: Checking remote repository..."
echo ""
# Check if remote exists
if ! git remote get-url origin &>/dev/null; then
echo "❌ No remote 'origin' configured"
echo "Add remote with:"
echo " git remote add origin https://github.com/netpack/XFB.git"
exit 1
fi
REMOTE_URL=$(git remote get-url origin)
echo "Remote URL: $REMOTE_URL"
# Verify it's the correct repository
if [[ ! "$REMOTE_URL" =~ "netpack/XFB" ]]; then
echo "⚠️ Warning: Remote URL doesn't match expected repository"
read -p "Continue anyway? (y/N) " -n 1 -r
echo ""
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "Push cancelled"
exit 1
fi
fi
echo ""
echo "Step 5: Checking branch..."
echo ""
CURRENT_BRANCH=$(git branch --show-current)
echo "Current branch: $CURRENT_BRANCH"
if [ "$CURRENT_BRANCH" != "main" ] && [ "$CURRENT_BRANCH" != "master" ]; then
echo "⚠️ Warning: Not on main/master branch"
read -p "Continue pushing to $CURRENT_BRANCH? (y/N) " -n 1 -r
echo ""
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "Push cancelled"
exit 1
fi
fi
echo ""
echo "Step 6: Files to be pushed..."
echo ""
# Show what will be pushed
echo "Recent commits:"
git log --oneline -5
echo ""
echo "Files in repository:"
git ls-files | head -20
echo "... (showing first 20 files)"
echo ""
echo "=========================================="
echo "Ready to Push"
echo "=========================================="
echo ""
echo "Repository: $REMOTE_URL"
echo "Branch: $CURRENT_BRANCH"
echo ""
read -p "Push to GitHub? (y/N) " -n 1 -r
echo ""
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo ""
echo "Pushing to GitHub..."
git push origin "$CURRENT_BRANCH"
echo ""
echo "=========================================="
echo "✓ Successfully pushed to GitHub!"
echo "=========================================="
echo ""
echo "View at: https://github.com/netpack/XFB"
echo ""
# Check if there are tags to push
if git tag | grep -q .; then
echo "Tags found in repository:"
git tag | tail -5
echo ""
read -p "Push tags as well? (y/N) " -n 1 -r
echo ""
if [[ $REPLY =~ ^[Yy]$ ]]; then
git push origin --tags
echo "✓ Tags pushed"
fi
fi
echo ""
echo "Next steps:"
echo "1. Update AUR: ./update-aur.sh"
echo "2. Create GitHub release with .deb file"
echo "3. Update Debian repository: ./update-debian-repo.sh"
else
echo "Push cancelled"
exit 0
fi