Bashbot Version 0.70

This commit is contained in:
Kay Marquardt (Gnadelwartz) 2019-05-01 14:36:34 +02:00
parent 6243be9982
commit e337b745bb
50 changed files with 65 additions and 63 deletions

1
.gitignore vendored
View File

@ -6,5 +6,4 @@
*.log
/JSON.sh/
/data-bot-bash/
/tmp-bot-bash/
/dist/

View File

@ -74,9 +74,9 @@
</ul>
<h2 id="security-considerations">Security Considerations</h2>
<p>Running a Telegram Bot means it is connected to the public and you never know whats send to your Bot.</p>
<p>Bash scripts in general are not designed to be bullet proof, so consider this Bot as a proof of concept. More concret examples of security problems are: bashs quoting hell and globbing. <a href="https://unix.stackexchange.com/questions/171346/security-implications-of-forgetting-to-quote-a-variable-in-bash-posix-shells">Implications of wrong quoting</a></p>
<p>Whenever you are processing input from from untrusted sources (messages, files, network) you must be as carefull as possible, e.g. set IFS appropriate, disable globbing (set -f) and quote everthing. In addition disable not used Bot commands and delete unused scripts from your Bot, e.g. example scripts notify, calc, question,</p>
<p>A powerful tool to improve your scripts robustness is <code>shellcheck</code>. You can <a href="https://www.shellcheck.net/">use it online</a> or <a href="https://github.com/koalaman/shellcheck#installing">install shellcheck locally</a>. All bashbot scripts are checked by shellcheck.</p>
<p>Bash scripts in general are not designed to be bullet proof, so consider this Bot as a proof of concept. Bash programmers often struggle with quoting hell and globbing, see <a href="https://unix.stackexchange.com/questions/171346/security-implications-of-forgetting-to-quote-a-variable-in-bash-posix-shells">Implications of wrong quoting</a></p>
<p>Whenever you are processing input from from untrusted sources (messages, files, network) you must be as carefull as possible, e.g. set IFS appropriate, disable globbing (set -f) and quote everthing. In addition delete unused scripts and examples from your Bot, e.g. scripts notify, calc, question, and disable all not used commands.</p>
<p>A powerful tool to improve your scripts is <code>shellcheck</code>. You can <a href="https://www.shellcheck.net/">use it online</a> or <a href="https://github.com/koalaman/shellcheck#installing">install shellcheck locally</a>. Shellcheck is used extensive in bashbot development to enshure a high code quality, e.g. its not allowed to push changes without passing all shellcheck tests. In addition bashbot has a <a href="doc/7_develop.md">test suite</a> to check if important functionality is working as expected.</p>
<h3 id="run-your-bot-as-a-restricted-user">Run your Bot as a restricted user</h3>
<p><strong>I recommend to run your bot as a user, with almost no access rights.</strong> All files your Bot have write access to are in danger to be overwritten/deleted if your bot is hacked. For the same reason ervery file your Bot can read is in danger to be disclosed. Restict your Bots access rigths to the absolute minimum.</p>
<p><strong>Never run your Bot as root, this is the most dangerous you can do!</strong> Usually the user nobody has almost no rights on Unix/Linux systems. See <a href="doc/4_expert.md">Expert use</a> on how to run your Bot as an other user.</p>
@ -97,6 +97,6 @@
<p><span class="citation">@Gnadelwartz</span></p>
<h2 id="thats-it">Thats it!</h2>
<p>If you feel that theres something missing or if you found a bug, feel free to submit a pull request!</p>
<h4 id="version-v0.70-rc1-0-g8883cc9"><br /><span class="math display"><em>V</em><em>E</em><em>R</em><em>S</em><em>I</em><em>O</em><em>N</em></span><br /> v0.70-rc1-0-g8883cc9</h4>
<h4 id="version-v0.70-0-g6243be9"><br /><span class="math display"><em>V</em><em>E</em><em>R</em><em>S</em><em>I</em><em>O</em><em>N</em></span><br /> v0.70-0-g6243be9</h4>
</body>
</html>

View File

@ -94,4 +94,4 @@ Well, thats a damn good question ... may be because I'm an Unix/Linux admin from
If you feel that there's something missing or if you found a bug, feel free to submit a pull request!
#### $$VERSION$$ v0.70-rc1-0-g8883cc9
#### $$VERSION$$ v0.70-0-g6243be9

View File

@ -65,21 +65,24 @@ Running a Telegram Bot means it is connected to the public and you never know
whats send to your Bot.
Bash scripts in general are not designed to be bullet proof, so consider this
Bot as a proof of concept. More concret examples of security problems are:
bash's 'quoting hell' and globbing. [Implications of wrong
Bot as a proof of concept. Bash programmers often struggle with 'quoting hell'
and globbing, see [Implications of wrong
quoting](https://unix.stackexchange.com/questions/171346/security-implications-o
f-forgetting-to-quote-a-variable-in-bash-posix-shells)
Whenever you are processing input from from untrusted sources (messages, files,
network) you must be as carefull as possible, e.g. set IFS appropriate, disable
globbing (set -f) and quote everthing. In addition disable not used Bot
commands and delete unused scripts from your Bot, e.g. example scripts
'notify', 'calc', 'question',
globbing (set -f) and quote everthing. In addition delete unused scripts and
examples from your Bot, e.g. scripts 'notify', 'calc', 'question', and disable
all not used commands.
A powerful tool to improve your scripts robustness is ```shellcheck```. You can
[use it online](https://www.shellcheck.net/) or [install shellcheck
locally](https://github.com/koalaman/shellcheck#installing). All bashbot
scripts are checked by shellcheck.
A powerful tool to improve your scripts is ```shellcheck```. You can [use it
online](https://www.shellcheck.net/) or [install shellcheck
locally](https://github.com/koalaman/shellcheck#installing). Shellcheck is used
extensive in bashbot development to enshure a high code quality, e.g. it's not
allowed to push changes without passing all shellcheck tests.
In addition bashbot has a [test suite](doc/7_develop.md) to check if important
functionality is working as expected.
### Run your Bot as a restricted user
**I recommend to run your bot as a user, with almost no access rights.**
@ -130,4 +133,4 @@ health status
If you feel that there's something missing or if you found a bug, feel free to
submit a pull request!
#### $$VERSION$$ v0.70-rc1-0-g8883cc9
#### $$VERSION$$ v0.70-0-g6243be9

View File

@ -1,7 +1,7 @@
#!/bin/sh
# description: Start or stop telegram-bash-bot
#
#### $$VERSION$$ v0.70-rc1-0-g8883cc9
#### $$VERSION$$ v0.70-0-g6243be9
# shellcheck disable=SC2009
# shellcheck disable=SC2181

View File

@ -12,7 +12,7 @@
# This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
#
#### $$VERSION$$ v0.70-rc1-0-g8883cc9
#### $$VERSION$$ v0.70-0-g6243be9
#
# Exit Codes:
# - 0 sucess (hopefully)

View File

@ -5,7 +5,7 @@
# This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
#
#### $$VERSION$$ v0.70-rc1-0-g8883cc9
#### $$VERSION$$ v0.70-0-g6243be9
#
# shellcheck disable=SC2154
# shellcheck disable=SC2034

View File

@ -1,7 +1,7 @@
#!/usr/bin/env bash
# this has to run once atfer git clone
# and every time we create new hooks
#### $$VERSION$$ v0.70-rc1-0-g8883cc9
#### $$VERSION$$ v0.70-0-g6243be9
# magic to ensure that we're always inside the root of our application,
# no matter from which directory we'll run script

View File

@ -3,7 +3,7 @@
#
# works together with git pre-push.sh and ADD all changed files since last push
#### $$VERSION$$ v0.70-rc1-0-g8883cc9
#### $$VERSION$$ v0.70-0-g6243be9
# magic to ensure that we're always inside the root of our application,
# no matter from which directory we'll run script

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash
#### $$VERSION$$ v0.70-rc1-0-g8883cc9
#### $$VERSION$$ v0.70-0-g6243be9
############
# NOTE: you MUST run install-hooks.sh again when updating this file!

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash
#### $$VERSION$$ v0.70-rc1-0-g8883cc9
#### $$VERSION$$ v0.70-0-g6243be9
############
# NOTE: you MUST run install-hooks.sh again when updating this file!

View File

@ -1,7 +1,7 @@
#!/usr/bin/env bash
# this has to run once atfer git clone
# and every time we create new hooks
#### $$VERSION$$ v0.70-rc1-0-g8883cc9
#### $$VERSION$$ v0.70-0-g6243be9
# magic to ensure that we're always inside the root of our application,
# no matter from which directory we'll run script

View File

@ -1,7 +1,7 @@
#!/usr/bin/env bash
# this has to run once atfer git clone
# and every time we create new hooks
#### $$VERSION$$ v0.70-rc1-0-g8883cc9
#### $$VERSION$$ v0.70-0-g6243be9
# magic to ensure that we're always inside the root of our application,
# no matter from which directory we'll run script

View File

@ -1,3 +1,3 @@
# list of additional files to check from shellcheck
#### $$VERSION$$ v0.70-rc1-0-g8883cc9
#### $$VERSION$$ v0.70-0-g6243be9
bashbot.rc

View File

@ -1,6 +1,6 @@
#!/bin/bash
#
#### $$VERSION$$ v0.70-rc1-0-g8883cc9
#### $$VERSION$$ v0.70-0-g6243be9
# shellcheck disable=SC2016
#
# Easy Versioning in git:

View File

@ -63,5 +63,5 @@ The old format is supported for backward compatibility, but may fail for corner
#### [Next Create Bot](1_firstbot.md)
#### $$VERSION$$ v0.70-rc1-0-g8883cc9
#### $$VERSION$$ v0.70-0-g6243be9

View File

@ -65,5 +65,5 @@ group. This step is up to you actually.
#### [Prev Installation](0_install.md)
#### [Next Getting started](2_usage.md)
#### $$VERSION$$ v0.70-rc1-0-g8883cc9
#### $$VERSION$$ v0.70-0-g6243be9

View File

@ -167,5 +167,5 @@ send_action "${CHAT[ID]}" "action"
#### [Prev Create Bot](1_firstbot.md)
#### [Next Advanced Usage](3_advanced.md)
#### $$VERSION$$ v0.70-rc1-0-g8883cc9
#### $$VERSION$$ v0.70-0-g6243be9

View File

@ -177,5 +177,5 @@ answer_inline_query "$iQUERY_ID" "cached_sticker" "identifier for the sticker"
#### [Prev Getting started](2_usage.md)
#### [Next Expert Use](4_expert.md)
#### $$VERSION$$ v0.70-rc1-0-g8883cc9
#### $$VERSION$$ v0.70-0-g6243be9

View File

@ -104,5 +104,5 @@ An example crontab is provided in ```examples/bashbot.cron```.
#### [Prev Expert Use](4_expert.md)
#### [Next Best Practice](5_practice.md)
#### $$VERSION$$ v0.70-rc1-0-g8883cc9
#### $$VERSION$$ v0.70-0-g6243be9

View File

@ -153,5 +153,5 @@ The second warning is about an unused variable, this is true because in our exam
#### [Prev Best Practice](5_practice.md)
#### [Next Functions Reference](6_reference.md)
#### $$VERSION$$ v0.70-rc1-0-g8883cc9
#### $$VERSION$$ v0.70-0-g6243be9

View File

@ -489,5 +489,5 @@ Send Input from Telegram to waiting Interactive Chat.
#### [Prev Best Practice](5_practice.md)
#### [Next Notes for Developers](7_develop.md)
#### $$VERSION$$ v0.70-rc1-0-g8883cc9
#### $$VERSION$$ v0.70-0-g6243be9

View File

@ -117,5 +117,5 @@ fi
#### [Prev Function Reference](6_reference.md)
#### [Next Bashbot Environment](8_custom.md)
#### $$VERSION$$ v0.70-rc1-0-g8883cc9
#### $$VERSION$$ v0.70-0-g6243be9

View File

@ -117,5 +117,5 @@ for every poll until the maximum of BASHBOT_SLEEP ms.
#### [Prev Notes for Developers](7_develop.md)
#### $$VERSION$$ v0.70-rc1-0-g8883cc9
#### $$VERSION$$ v0.70-0-g6243be9

View File

@ -55,6 +55,6 @@ convert existing bots.
**external-use** will contain some examples on how to send messages from external scripts to Telegram chats or users.
#### $$VERSION$$ v0.70-rc1-0-g8883cc9
#### $$VERSION$$ v0.70-0-g6243be9

View File

@ -4,7 +4,7 @@
# This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
#### $$VERSION$$ v0.70-rc1-0-g8883cc9
#### $$VERSION$$ v0.70-0-g6243be9
# adjust your language setting here
# https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment

View File

@ -2,7 +2,7 @@
# file: run_filename
# background job to display content of all new files in WATCHDIR
#
#### $$VERSION$$ v0.70-rc1-0-g8883cc9
#### $$VERSION$$ v0.70-0-g6243be9
# adjust your language setting here
# https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment

View File

@ -2,7 +2,7 @@
# file: run_filename
# background job to display all new files in WATCHDIR
#
#### $$VERSION$$ v0.70-rc1-0-g8883cc9
#### $$VERSION$$ v0.70-0-g6243be9
# adjust your language setting here
# https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment

View File

@ -4,7 +4,7 @@
# This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
#### $$VERSION$$ v0.70-rc1-0-g8883cc9
#### $$VERSION$$ v0.70-0-g6243be9
# adjust your language setting here
# https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment

View File

@ -2,7 +2,7 @@
# file. multibot.sh
# description: run multiple telegram bots from one installation
#
#### $$VERSION$$ v0.70-rc1-0-g8883cc9
#### $$VERSION$$ v0.70-0-g6243be9
if [ "${2}" = "" ] || [ "${2}" = "-h" ]; then
echo "Usage: $0 botname command"
@ -41,4 +41,4 @@ export BASHBOT_VAR="${VAR}/${BOT}"
[ ! -r "${BASHBOT_ETC}/commands.sh" ] && echo "${BASHBOT_ETC}/commands.sh not readable or does not exist" && exit 1
[ ! -r "${BASHBOT_ETC}/mycommands.sh" ] && echo "${BASHBOT_ETC}/mycommands.sh not readable or does not exist" && exit 1
"${BINDIR}/bashbot.sh" $2
"${BINDIR}/bashbot.sh" "$2"

View File

@ -7,7 +7,7 @@
# This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
#
#### $$VERSION$$ v0.70-rc1-0-g8883cc9
#### $$VERSION$$ v0.70-0-g6243be9
SHELL=/bin/sh

View File

@ -5,7 +5,7 @@
# This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
#### $$VERSION$$ v0.70-rc1-0-g8883cc9
#### $$VERSION$$ v0.70-0-g6243be9
# adjust your language setting here
# https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment

View File

@ -4,7 +4,7 @@
# This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
#### $$VERSION$$ v0.70-rc1-0-g8883cc9
#### $$VERSION$$ v0.70-0-g6243be9
# adjust your language setting here
# https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment

View File

@ -5,7 +5,7 @@
# This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
#### $$VERSION$$ v0.70-rc1-0-g8883cc9
#### $$VERSION$$ v0.70-0-g6243be9
# adjust your language setting here
# https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment

View File

@ -1,7 +1,7 @@
# file: botacl
# a user not listed here, will return false from 'user_is_allowed'
#
#### $$VERSION$$ v0.70-rc1-0-g8883cc9
#### $$VERSION$$ v0.70-0-g6243be9
# Format:
# user:ressource:chat

View File

@ -5,7 +5,7 @@
# to show how you can customize bashbot by only editing mycommands.sh
# NOTE: this is not tested, simply copied from original source and reworked!
#
#### $$VERSION$$ v0.70-rc1-0-g8883cc9
#### $$VERSION$$ v0.70-0-g6243be9
#
# shellcheck disable=SC2154
# shellcheck disable=SC2034

View File

@ -5,7 +5,7 @@
# This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
#
#### $$VERSION$$ v0.70-rc1-0-g8883cc9
#### $$VERSION$$ v0.70-0-g6243be9
#
# source from commands.sh to use the aliases

View File

@ -5,7 +5,7 @@
# This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
#
#### $$VERSION$$ v0.70-rc1-0-g8883cc9
#### $$VERSION$$ v0.70-0-g6243be9
# source from commands.sh if you want ro use interactive or background jobs

View File

@ -5,6 +5,6 @@
# This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
#
#### $$VERSION$$ v0.70-rc1-0-g8883cc9
#### $$VERSION$$ v0.70-0-g6243be9
# source from commands.sh to use the inline functions

View File

@ -2,7 +2,7 @@
# files: mycommands.sh.dist
# copy to mycommands.sh and add all your commands and functions here ...
#
#### $$VERSION$$ v0.70-rc1-0-g8883cc9
#### $$VERSION$$ v0.70-0-g6243be9
#
# shellcheck disable=SC2154
# shellcheck disable=SC2034

View File

@ -2,7 +2,7 @@
#
# ADD a new test skeleton to test dir, but does not activate test
#
#### $$VERSION$$ v0.70-rc1-0-g8883cc9
#### $$VERSION$$ v0.70-0-g6243be9
# magic to ensure that we're always inside the root of our application,
# no matter from which directory we'll run script

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash
#### $$VERSION$$ v0.70-rc1-0-g8883cc9
#### $$VERSION$$ v0.70-0-g6243be9
# common variables
export TESTME DIRME TESTDIR LOGFILE REFDIR TESTNAME

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash
#### $$VERSION$$ v0.70-rc1-0-g8883cc9
#### $$VERSION$$ v0.70-0-g6243be9
../dev/hooks/pre-commit.sh

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash
# file: b-example-test.sh
#### $$VERSION$$ v0.70-rc1-0-g8883cc9
#### $$VERSION$$ v0.70-0-g6243be9
# include common functions and definitions
# shellcheck source=test/ALL-tests.inc.sh

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash
#### $$VERSION$$ v0.70-rc1-0-g8883cc9
#### $$VERSION$$ v0.70-0-g6243be9
# include common functions and definitions
# shellcheck source=test/ALL-tests.inc.sh

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash
#### $$VERSION$$ v0.70-rc1-0-g8883cc9
#### $$VERSION$$ v0.70-0-g6243be9
# include common functions and definitions
# shellcheck source=test/ALL-tests.inc.sh

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash
#### $$VERSION$$ v0.70-rc1-0-g8883cc9
#### $$VERSION$$ v0.70-0-g6243be9
# include common functions and definitions
# shellcheck source=test/ALL-tests.inc.sh

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash
#### $$VERSION$$ v0.70-rc1-0-g8883cc9
#### $$VERSION$$ v0.70-0-g6243be9
# include common functions and definitions
# shellcheck source=test/ALL-tests.inc.sh

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash
#### $$VERSION$$ v0.70-rc1-0-g8883cc9
#### $$VERSION$$ v0.70-0-g6243be9
# include common functions and definitions
# shellcheck source=test/ALL-tests.inc.sh

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash
#### $$VERSION$$ v0.70-rc1-0-g8883cc9
#### $$VERSION$$ v0.70-0-g6243be9
# include common functions and definitions
# shellcheck source=test/ALL-tests.inc.sh