version 0.0
+ creating basic workflow ( settings and tracking work ) + download git repos + find for pem, zip and pub files + creating raw report Squashed commit of the following: commit 114b748622636719fcd46c35ff00bff4ea5765b4 Author: Umgeher Torgersen <me@umgeher.org> Date: Wed Apr 26 18:57:38 2023 +0000 version 0.0 is done commit a2cfcda73639e5c09b30e2e704cffde5e3b9e6d5 Author: Umgeher Torgersen <me@umgeher.org> Date: Wed Apr 26 18:43:31 2023 +0000 0.1? commit cbbefc8c4ad112a9f5bbee03dd8b32d4da52541a Author: Umgeher Torgersen <me@umgeher.org> Date: Wed Apr 26 18:05:43 2023 +0000 seeking for pem, zip and pub files commit 5dcafdf9f77a3dc231068c2355b2b89990395788 Author: Umgeher Torgersen <me@umgeher.org> Date: Wed Apr 26 16:53:17 2023 +0000 rep-stats commit e911c19f0257fab391638b6f2b942dded825d7a1 Author: Umgeher Torgersen <me@umgeher.org> Date: Wed Apr 26 16:06:29 2023 +0000 just some sort commit 9ac24cc73116e0a0f944fa46e2f76cd3b189fd3c Author: Umgeher Torgersen <me@umgeher.org> Date: Wed Apr 26 16:02:53 2023 +0000 cmd_run stuff commit f49879b01ab47c837bcaab06b3826139f6a7ee9d Author: Umgeher Torgersen <me@umgeher.org> Date: Tue Apr 25 18:40:19 2023 +0000 draft commit 8d52cd2feb024702ed6142ad800b5c1c409383ac Author: Umgeher Torgersen <me@umgeher.org> Date: Tue Apr 25 16:47:08 2023 +0000 tree -> config url added commit e2f0061519f122b962f2f7a1b77d75d8b6cd0fa4 Author: Umgeher Torgersen <me@umgeher.org> Date: Tue Apr 25 16:31:15 2023 +0000 config: group add and delete commit 20768b0f4312d1e5c84fa2343cbac8fcbed1752e Author: Umgeher Torgersen <me@umgeher.org> Date: Tue Apr 25 16:21:12 2023 +0000 draft: some basic stuff
This commit is contained in:
parent
7d230bd68d
commit
2c02c892e3
1 changed files with 265 additions and 0 deletions
265
gseeker
Executable file
265
gseeker
Executable file
|
@ -0,0 +1,265 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
### DEFINE
|
||||||
|
|
||||||
|
VERSION="0.0"
|
||||||
|
GSEEKER_HOME="$HOME/.gseeker"
|
||||||
|
GSEEKER_REPORTS="$GSEEKER_HOME/reports"
|
||||||
|
GSEEKER_TMPDIR="$GSEEKER_HOME/tmp/pid_$$"
|
||||||
|
GSEEKER_TREPORT="$GSEEKER_TMPDIR/report"
|
||||||
|
GSEEKER_CONFIG="$GSEEKER_HOME/config"
|
||||||
|
GSEEKER_TRACKER="$GSEEKER_HOME/tracker"
|
||||||
|
|
||||||
|
###
|
||||||
|
|
||||||
|
cleanup() {
|
||||||
|
rm -rf $GSEEKER_TMPDIR
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd_tree() {
|
||||||
|
case $1 in
|
||||||
|
config )
|
||||||
|
cmd_tree_config $*
|
||||||
|
;;
|
||||||
|
run )
|
||||||
|
cmd_tree_run $*
|
||||||
|
;;
|
||||||
|
show )
|
||||||
|
cmd_tree_show $*
|
||||||
|
;;
|
||||||
|
* )
|
||||||
|
echo "usage: $0 <command> [<args>]"
|
||||||
|
echo ""
|
||||||
|
echo "These are common gseeker commands used in various situations:"
|
||||||
|
echo ""
|
||||||
|
echo " config add and delete settings"
|
||||||
|
echo " show show metadata"
|
||||||
|
echo ""
|
||||||
|
echo "See '$0 help <command>' to read about a specific subcommand."
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd_tree_config() {
|
||||||
|
case $2 in
|
||||||
|
group )
|
||||||
|
cmd_tree_config_group $*
|
||||||
|
;;
|
||||||
|
url )
|
||||||
|
cmd_tree_config_url $*
|
||||||
|
;;
|
||||||
|
* )
|
||||||
|
echo "usage: $0 config <command> [<args>]"
|
||||||
|
echo ""
|
||||||
|
echo " group "
|
||||||
|
echo " url "
|
||||||
|
echo ""
|
||||||
|
echo "See '$0 help config <command>' to read about a specific subcommand."
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd_tree_config_group() {
|
||||||
|
case $3 in
|
||||||
|
add )
|
||||||
|
cmd_tree_config_group_add $*
|
||||||
|
;;
|
||||||
|
del )
|
||||||
|
cmd_tree_config_group_del $*
|
||||||
|
;;
|
||||||
|
* )
|
||||||
|
echo "usage: $0 config group <command> [<args>]"
|
||||||
|
echo ""
|
||||||
|
echo " add "
|
||||||
|
echo " del "
|
||||||
|
echo ""
|
||||||
|
echo "See '$0 help config group <command>' to read about a specific subcommand."
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd_tree_config_group_add() {
|
||||||
|
if [[ -n $4 ]]; then
|
||||||
|
HASH=$(sha1 -qs $4)
|
||||||
|
echo "group,name,$4,$HASH" >> $GSEEKER_CONFIG
|
||||||
|
else
|
||||||
|
echo "usage: $0 config group add <name>"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd_tree_config_group_del() {
|
||||||
|
if [[ -n $4 ]]; then
|
||||||
|
sed -i "/group,name,$4,/d" $GSEEKER_CONFIG
|
||||||
|
else
|
||||||
|
echo "usage: $0 config group del <name>"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd_tree_config_url() {
|
||||||
|
case $3 in
|
||||||
|
add )
|
||||||
|
cmd_tree_config_url_add $*
|
||||||
|
;;
|
||||||
|
del )
|
||||||
|
cmd_tree_config_url_del $*
|
||||||
|
;;
|
||||||
|
* )
|
||||||
|
echo "usage: $0 config url <command> [<args>]"
|
||||||
|
echo ""
|
||||||
|
echo "..."
|
||||||
|
echo ""
|
||||||
|
echo "See '$0 help config url <command>' to read about a specific subcommand."
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd_tree_config_url_add() {
|
||||||
|
if [[ -n $4 && -n $5 ]]; then
|
||||||
|
echo "url,$(sha1 -qs $4),$(sha1 -qs $5),$4" >> $GSEEKER_CONFIG
|
||||||
|
else
|
||||||
|
echo "usage: $0 config url add <url> <group>"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd_tree_config_url_del() {
|
||||||
|
if [[ -n $4 && -n $5 ]]; then
|
||||||
|
sed -i "/url,$4,$(sha1 -qs $5),/d" $GSEEKER_CONFIG
|
||||||
|
else
|
||||||
|
echo "usage: $0 config url del <id> <group>"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd_tree_run() {
|
||||||
|
if [[ -n $2 ]]; then
|
||||||
|
GROUP_HASH=$(sha1 -qs $2)
|
||||||
|
|
||||||
|
if [[ -n $(cat $GSEEKER_CONFIG | grep $GROUP_HASH) ]]; then
|
||||||
|
if [[ -n $3 ]]; then
|
||||||
|
if [[ -n $(cat $GSEEKER_CONFIG | grep $3) ]]; then
|
||||||
|
rep_run $GROUP_HASH $3
|
||||||
|
else
|
||||||
|
echo "error: repo $3 not found"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
group_run $GROUP_HASH
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "error: group $2 not found"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
for GROUP in $(cat $GSEEKER_CONFIG | grep "group,name," | cut -f4 -d,); do
|
||||||
|
group_run $GROUP
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd_tree_show() {
|
||||||
|
case $2 in
|
||||||
|
config )
|
||||||
|
cat $GSEEKER_CONFIG
|
||||||
|
;;
|
||||||
|
* )
|
||||||
|
echo "usage: $0 show <command>"
|
||||||
|
echo ""
|
||||||
|
echo " config -- show configurations"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
group_run() {
|
||||||
|
for HASH in $(cat $GSEEKER_CONFIG | grep $1 | grep "url," | cut -f2 -d,); do
|
||||||
|
rep_run $1 $HASH
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
main() {
|
||||||
|
setup
|
||||||
|
cmd_tree $*
|
||||||
|
cleanup
|
||||||
|
}
|
||||||
|
|
||||||
|
rep_run() {
|
||||||
|
URL=$(cat $GSEEKER_CONFIG | grep "$2,$1" | cut -f4 -d,)
|
||||||
|
mkdir -p $GSEEKER_TMPDIR/$1/
|
||||||
|
git clone $URL $GSEEKER_TMPDIR/$1/$2
|
||||||
|
rep_stats $1 $2
|
||||||
|
}
|
||||||
|
|
||||||
|
rep_stats() {
|
||||||
|
FILE="$GSEEKER_TREPORT/repo_$2"
|
||||||
|
DATE=$(date +%s)
|
||||||
|
echo "date,$DATE" >> $FILE
|
||||||
|
echo "version,$VERSION" >> $FILE
|
||||||
|
echo "url,$(cd $GSEEKER_TMPDIR/$1/$2 ; git info | grep 'remote.origin.url=' | cut -f2 -d'=')" >> $FILE
|
||||||
|
echo "head,$(cd $GSEEKER_TMPDIR/$1/$2 ; git info | grep ' origin/HEAD' | sed 's/ origin\/HEAD -> origin\///g')" >> $FILE
|
||||||
|
echo "commit,last,$(cd $GSEEKER_TMPDIR/$1/$2 ; git info | grep 'commit ' | sed 's/commit //g')" >> $FILE
|
||||||
|
|
||||||
|
for BRANCH in $(cd $GSEEKER_TMPDIR/$1/$2 ; git info | grep ' origin/' | grep -v 'HEAD' | sed 's/origin\///g'); do
|
||||||
|
echo "branch,$BRANCH" >> $FILE
|
||||||
|
done
|
||||||
|
|
||||||
|
for LINE in $(cd $GSEEKER_TMPDIR/$1/$2 ; git shortlog -se | tr '\t' ',' | sed 's/ /_/g'); do
|
||||||
|
COMMITS=$(echo $LINE | cut -f1 -d, | sed 's/_//g')
|
||||||
|
NAME=$(echo $LINE | cut -f2 -d, | sed 's/_</</g' | cut -f1 -d'<' | sed 's/_/ /g')
|
||||||
|
EMAIL=$(echo $LINE | cut -f2 -d'<' | sed 's/>//g')
|
||||||
|
echo "shortlog,$EMAIL,$NAME,$COMMITS" >> $FILE
|
||||||
|
done
|
||||||
|
|
||||||
|
$(cat $GSEEKER_TRACKER | grep "commit,number," | grep ",$2,$1" | cut -f3 -d, > $GSEEKER_TMPDIR/tracker_$2_$1)
|
||||||
|
$(cd $GSEEKER_TMPDIR/$1/$2 ; git log --oneline | nl | sort -rn | cut -f2 | cut -d" " -f1 > $GSEEKER_TMPDIR/cn_$2_$1)
|
||||||
|
|
||||||
|
for CNUMBER in $(grep -Fvf $GSEEKER_TMPDIR/tracker_$2_$1 $GSEEKER_TMPDIR/cn_$2_$1); do
|
||||||
|
$(cd $GSEEKER_TMPDIR/$1/$2 ; git checkout $CNUMBER)
|
||||||
|
echo "commit,number,$CNUMBER" >> $FILE
|
||||||
|
F_PEM=$(cd $GSEEKER_TMPDIR/$1/$2 ; find . -type f -name "*.pem")
|
||||||
|
|
||||||
|
if [[ -n $F_PEM ]]; then
|
||||||
|
for TF in $F_PEM; do
|
||||||
|
HASH=$(cd $GSEEKER_TMPDIR/$1/$2 ; sha1 -q $TF)
|
||||||
|
|
||||||
|
if [[ -z $(cat $FILE | grep "file,alert,$HASH,") ]]; then
|
||||||
|
echo "file,alert,$HASH,$CNUMBER,$TF" >> $FILE
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
F_ZIP=$(cd $GSEEKER_TMPDIR/$1/$2 ; find . -type f -name "*.zip")
|
||||||
|
|
||||||
|
if [[ -n $F_ZIP ]]; then
|
||||||
|
for TF in $F_ZIP; do
|
||||||
|
HASH=$(cd $GSEEKER_TMPDIR/$1/$2 ; sha1 -q $TF)
|
||||||
|
|
||||||
|
if [[ -z $(cat $FILE | grep "file,alert,$HASH,") ]]; then
|
||||||
|
echo "file,alert,$HASH,$CNUMBER,$TF" >> $FILE
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
F_PUB=$(cd $GSEEKER_TMPDIR/$1/$2 ; find . -type f -name "*.pub")
|
||||||
|
|
||||||
|
if [[ -n $F_PUB ]]; then
|
||||||
|
for TF in $F_PUB; do
|
||||||
|
HASH=$(cd $GSEEKER_TMPDIR/$1/$2 ; sha1 -q $TF)
|
||||||
|
|
||||||
|
if [[ -z $(cat $FILE | grep "file,alert,$HASH,") ]]; then
|
||||||
|
echo "file,alert,$HASH,$CNUMBER,$TF" >> $FILE
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "commit,number,$CNUMBER,$2,$1" >> $GSEEKER_TRACKER
|
||||||
|
done
|
||||||
|
|
||||||
|
cp $FILE "$GSEEKER_REPORTS/report-$DATE-$2-$1.gseeker"
|
||||||
|
}
|
||||||
|
|
||||||
|
setup() {
|
||||||
|
test -d $GSEEKER_HOME || (mkdir -p $GSEEKER_HOME)
|
||||||
|
test -d $GSEEKER_REPORTS || (mkdir -p $GSEEKER_REPORTS)
|
||||||
|
test -d $GSEEKER_TMPDIR || (mkdir -p $GSEEKER_TMPDIR)
|
||||||
|
test -d $GSEEKER_TREPORT || (mkdir -p $GSEEKER_TREPORT)
|
||||||
|
test -f $GSEEKER_CONFIG || (touch $GSEEKER_CONFIG)
|
||||||
|
test -f $GSEEKER_TRACKER || (touch $GSEEKER_TRACKER)
|
||||||
|
}
|
||||||
|
|
||||||
|
main $*
|
Loading…
Add table
Add a link
Reference in a new issue