Compare commits
2 commits
Author | SHA1 | Date | |
---|---|---|---|
c19c75eb34 | |||
4e4cc31c13 |
2 changed files with 195 additions and 48 deletions
231
gseeker
231
gseeker
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
### DEFINE
|
### DEFINE
|
||||||
|
|
||||||
VERSION="0.1"
|
VERSION="0.3"
|
||||||
GSEEKER_HOME="$HOME/.gseeker"
|
GSEEKER_HOME="$HOME/.gseeker"
|
||||||
GSEEKER_REPORTS="$GSEEKER_HOME/reports"
|
GSEEKER_REPORTS="$GSEEKER_HOME/reports"
|
||||||
GSEEKER_TMPDIR="$GSEEKER_HOME/tmp/pid_$$"
|
GSEEKER_TMPDIR="$GSEEKER_HOME/tmp/pid_$$"
|
||||||
|
@ -27,6 +27,9 @@ cmd_tree() {
|
||||||
show )
|
show )
|
||||||
cmd_tree_show $*
|
cmd_tree_show $*
|
||||||
;;
|
;;
|
||||||
|
help )
|
||||||
|
cmd_tree_help $*
|
||||||
|
;;
|
||||||
* )
|
* )
|
||||||
echo "usage: $0 <command> [<args>]"
|
echo "usage: $0 <command> [<args>]"
|
||||||
echo ""
|
echo ""
|
||||||
|
@ -34,12 +37,163 @@ cmd_tree() {
|
||||||
echo ""
|
echo ""
|
||||||
echo " config add and delete settings"
|
echo " config add and delete settings"
|
||||||
echo " show show metadata"
|
echo " show show metadata"
|
||||||
|
echo " run run diagnostics on chosen URL's or groups added through <config>"
|
||||||
echo ""
|
echo ""
|
||||||
echo "See '$0 help <command>' to read about a specific subcommand."
|
echo "See '$0 help <command>' to read about a specific subcommand."
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cmd_tree_help() {
|
||||||
|
case $2 in
|
||||||
|
config )
|
||||||
|
cmd_tree_help_config $*
|
||||||
|
;;
|
||||||
|
show )
|
||||||
|
cmd_tree_help_show $*
|
||||||
|
;;
|
||||||
|
run )
|
||||||
|
cmd_tree_help_run $*
|
||||||
|
;;
|
||||||
|
* )
|
||||||
|
echo "usage: $0 help <args>"
|
||||||
|
echo ""
|
||||||
|
echo " config show help for the config command"
|
||||||
|
echo " show show help for the show command"
|
||||||
|
echo " run show help for the run command"
|
||||||
|
echo ""
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd_tree_help_config() {
|
||||||
|
case $3 in
|
||||||
|
group )
|
||||||
|
cmd_tree_help_config_group $*
|
||||||
|
;;
|
||||||
|
url )
|
||||||
|
cmd_tree_help_config_url $*
|
||||||
|
;;
|
||||||
|
* )
|
||||||
|
echo "usage: $0 help config [group, url]"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd_tree_help_config_group() {
|
||||||
|
case $4 in
|
||||||
|
add )
|
||||||
|
echo "usage: $0 config group add <group>"
|
||||||
|
echo ""
|
||||||
|
echo "Examples"
|
||||||
|
echo ""
|
||||||
|
echo " $0 config group add testingGroup"
|
||||||
|
echo " $0 config group add anotherGroup"
|
||||||
|
;;
|
||||||
|
del )
|
||||||
|
echo "usage: $0 config group del <group>"
|
||||||
|
echo ""
|
||||||
|
echo "Examples:"
|
||||||
|
echo ""
|
||||||
|
echo " $0 config group del testingGroup"
|
||||||
|
echo " $0 config group del anotherGroup"
|
||||||
|
;;
|
||||||
|
* )
|
||||||
|
echo "usage: $0 help config group [add, del]"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd_tree_help_config_url() {
|
||||||
|
case $4 in
|
||||||
|
add )
|
||||||
|
echo "usage: $0 config url add <url> <group>"
|
||||||
|
echo ""
|
||||||
|
echo "Examples:"
|
||||||
|
echo ""
|
||||||
|
echo '$0 config url add "https://git.sr.ht/~umgeher/gseeker" gseekerGroup'
|
||||||
|
echo '$0 config url add "https://git.sr.ht/~someperson/someproject" someGroup'
|
||||||
|
;;
|
||||||
|
del )
|
||||||
|
echo "usage: $0 config url del <id> <group>"
|
||||||
|
echo ""
|
||||||
|
echo "Examples:"
|
||||||
|
echo ""
|
||||||
|
echo '$0 config url del 05e8314dd1e2552e7d124048fba8f275d4ad0f60 gseekerGroup'
|
||||||
|
echo '$0 config url del cbbb2a6efd6217a48fd16b5c9430f2876bab222a someGroup'
|
||||||
|
echo ""
|
||||||
|
echo "<id> are the sha1 hashes of the URL's"
|
||||||
|
;;
|
||||||
|
* )
|
||||||
|
echo "usage: $0 help config url [add, del]"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd_tree_help_show() {
|
||||||
|
case $3 in
|
||||||
|
config )
|
||||||
|
echo "prints all URL's and groups added to the config file through the"
|
||||||
|
echo '"config [group, url] add <args>" command to standard output'
|
||||||
|
echo ""
|
||||||
|
echo "Example:"
|
||||||
|
echo ""
|
||||||
|
echo "$0 show config"
|
||||||
|
;;
|
||||||
|
* )
|
||||||
|
echo "usage: $0 help show config"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd_tree_help_run() {
|
||||||
|
case $3 in
|
||||||
|
null )
|
||||||
|
echo 'where "null" stands for no following <args>:'
|
||||||
|
echo ""
|
||||||
|
echo "runs diagnostics on all URL's found within any group in the config"
|
||||||
|
echo "file"
|
||||||
|
echo ""
|
||||||
|
echo "Example:"
|
||||||
|
echo ""
|
||||||
|
echo "$0 run"
|
||||||
|
;;
|
||||||
|
group )
|
||||||
|
cmd_tree_help_run_group $*
|
||||||
|
;;
|
||||||
|
* )
|
||||||
|
echo "usage: $0 help run [null, group]"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd_tree_help_run_group() {
|
||||||
|
case $4 in
|
||||||
|
null )
|
||||||
|
echo 'where "null" stands for no following <args>:'
|
||||||
|
echo ""
|
||||||
|
echo "runs diagnostics on all URL's found within the specified group in the"
|
||||||
|
echo "config file"
|
||||||
|
echo ""
|
||||||
|
echo "Example:"
|
||||||
|
echo ""
|
||||||
|
echo "$0 run gseekerGroup"
|
||||||
|
echo "$0 run someGroup"
|
||||||
|
;;
|
||||||
|
url )
|
||||||
|
echo "runs diagnostics on the specified URL found in the specified group"
|
||||||
|
echo ""
|
||||||
|
echo "Example:"
|
||||||
|
echo ""
|
||||||
|
echo '$0 run gseekerGroup "https://git.sr.ht/~umgeher/gseeker"'
|
||||||
|
echo '$0 run someGroup "https://git.sr.ht/~someperson/someproject"'
|
||||||
|
;;
|
||||||
|
* )
|
||||||
|
echo "usage: $0 help run group [null, url]"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
cmd_tree_config() {
|
cmd_tree_config() {
|
||||||
case $2 in
|
case $2 in
|
||||||
group )
|
group )
|
||||||
|
@ -51,8 +205,8 @@ cmd_tree_config() {
|
||||||
* )
|
* )
|
||||||
echo "usage: $0 config <command> [<args>]"
|
echo "usage: $0 config <command> [<args>]"
|
||||||
echo ""
|
echo ""
|
||||||
echo " group "
|
echo " group add or delete a group from the config file"
|
||||||
echo " url "
|
echo " url add or delete a URL from the config file"
|
||||||
echo ""
|
echo ""
|
||||||
echo "See '$0 help config <command>' to read about a specific subcommand."
|
echo "See '$0 help config <command>' to read about a specific subcommand."
|
||||||
;;
|
;;
|
||||||
|
@ -70,8 +224,8 @@ cmd_tree_config_group() {
|
||||||
* )
|
* )
|
||||||
echo "usage: $0 config group <command> [<args>]"
|
echo "usage: $0 config group <command> [<args>]"
|
||||||
echo ""
|
echo ""
|
||||||
echo " add "
|
echo " add add a group to the config file"
|
||||||
echo " del "
|
echo " del delete a group from the config file"
|
||||||
echo ""
|
echo ""
|
||||||
echo "See '$0 help config group <command>' to read about a specific subcommand."
|
echo "See '$0 help config group <command>' to read about a specific subcommand."
|
||||||
;;
|
;;
|
||||||
|
@ -106,7 +260,8 @@ cmd_tree_config_url() {
|
||||||
* )
|
* )
|
||||||
echo "usage: $0 config url <command> [<args>]"
|
echo "usage: $0 config url <command> [<args>]"
|
||||||
echo ""
|
echo ""
|
||||||
echo "..."
|
echo " add add a URL to the config file"
|
||||||
|
echo " del delete a URL from the config file"
|
||||||
echo ""
|
echo ""
|
||||||
echo "See '$0 help config url <command>' to read about a specific subcommand."
|
echo "See '$0 help config url <command>' to read about a specific subcommand."
|
||||||
;;
|
;;
|
||||||
|
@ -161,7 +316,7 @@ cmd_tree_show() {
|
||||||
* )
|
* )
|
||||||
echo "usage: $0 show <command>"
|
echo "usage: $0 show <command>"
|
||||||
echo ""
|
echo ""
|
||||||
echo " config -- show configurations"
|
echo "See '$0 help show <command>' to read about a specific subcommand."
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
@ -190,11 +345,12 @@ rep_stats() {
|
||||||
DATE=$(date +%s)
|
DATE=$(date +%s)
|
||||||
echo "date,$DATE" >> $FILE
|
echo "date,$DATE" >> $FILE
|
||||||
echo "version,$VERSION" >> $FILE
|
echo "version,$VERSION" >> $FILE
|
||||||
echo "url,$(cd $GSEEKER_TMPDIR/$1/$2 ; git info | grep 'remote.origin.url=' | cut -f2 -d'=')" >> $FILE
|
echo "url,$(cd $GSEEKER_TMPDIR/$1/$2 ; git config --list | 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 "head,$(cd $GSEEKER_TMPDIR/$1/$2 ; git branch -r | 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
|
echo "commit,last,$(cd $GSEEKER_TMPDIR/$1/$2 ; git log --max-count=1 --pretty=short | grep 'commit ' | sed 's/commit //g')" >> $FILE
|
||||||
|
echo "size,pack,$(cd $GSEEKER_TMPDIR/$1/$2 ; git count-objects -vH | grep "size-pack" | sed 's/size-pack: //g')" >> $FILE
|
||||||
|
|
||||||
for BRANCH in $(cd $GSEEKER_TMPDIR/$1/$2 ; git info | grep ' origin/' | grep -v 'HEAD' | sed 's/origin\///g'); do
|
for BRANCH in $(cd $GSEEKER_TMPDIR/$1/$2 ; git branch -r | grep ' origin/' | grep -v 'HEAD' | sed 's/origin\///g'); do
|
||||||
echo "branch,$BRANCH" >> $FILE
|
echo "branch,$BRANCH" >> $FILE
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -211,48 +367,29 @@ rep_stats() {
|
||||||
for CNUMBER in $(grep -Fvf $GSEEKER_TMPDIR/tracker_$2_$1 $GSEEKER_TMPDIR/cn_$2_$1); do
|
for CNUMBER in $(grep -Fvf $GSEEKER_TMPDIR/tracker_$2_$1 $GSEEKER_TMPDIR/cn_$2_$1); do
|
||||||
$(cd $GSEEKER_TMPDIR/$1/$2 ; git checkout $CNUMBER)
|
$(cd $GSEEKER_TMPDIR/$1/$2 ; git checkout $CNUMBER)
|
||||||
echo "commit,number,$CNUMBER" >> $FILE
|
echo "commit,number,$CNUMBER" >> $FILE
|
||||||
F_PEM=$(cd $GSEEKER_TMPDIR/$1/$2 ; find . -type f -name "*.pem")
|
scan_file_alert $1 $2
|
||||||
|
|
||||||
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
|
echo "commit,number,$CNUMBER,$2,$1" >> $GSEEKER_TRACKER
|
||||||
done
|
done
|
||||||
|
|
||||||
cp $FILE "$GSEEKER_REPORTS/report-$DATE-$2-$1.gseeker"
|
cp $FILE "$GSEEKER_REPORTS/report-$DATE-$2-$1.gseeker"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
scan_file_alert() {
|
||||||
|
for FTYPE in "*.pem" "*.zip" "*.pub"; do
|
||||||
|
FLIST=$(cd $GSEEKER_TMPDIR/$1/$2 ; find . -type f -name $FTYPE)
|
||||||
|
|
||||||
|
if [[ -n $FLIST ]]; then
|
||||||
|
for TF in $FLIST; 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
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
setup() {
|
setup() {
|
||||||
test -d $GSEEKER_HOME || (mkdir -p $GSEEKER_HOME)
|
test -d $GSEEKER_HOME || (mkdir -p $GSEEKER_HOME)
|
||||||
test -d $GSEEKER_REPORTS || (mkdir -p $GSEEKER_REPORTS)
|
test -d $GSEEKER_REPORTS || (mkdir -p $GSEEKER_REPORTS)
|
||||||
|
|
10
makefile
Normal file
10
makefile
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
.PHONY: install uninstall
|
||||||
|
.MAIN: install
|
||||||
|
|
||||||
|
install:
|
||||||
|
mkdir -p ~/bin
|
||||||
|
cp -v gseeker ~/bin
|
||||||
|
chmod +x ~/bin/gseeker
|
||||||
|
|
||||||
|
uninstall:
|
||||||
|
rm -vf ~/bin/gseeker
|
Loading…
Add table
Add a link
Reference in a new issue