Prevent Bots from running BotCommands #36

Merged
modulatingforce merged 2 commits from Cmds_Cannot_Be_Ran_by_Bots into main 2024-03-20 19:58:26 -04:00

Relatively easy validation check . Should involve following

  • Cmd Sender should be validated first if Bot or not

  • Ideally a Configurable Shared Config file that could be adjusted if required in future , noting a list of known Bots


Potentially Related Areas

https://git.flake.sh/modulatingforce/forcebot_rs/src/branch/main/src/core/botinstance.rs#L277
https://git.flake.sh/modulatingforce/forcebot_rs/src/branch/main/src/core/botinstance.rs#L274
https://git.flake.sh/modulatingforce/forcebot_rs/src/branch/main/src/core/identity.rs#L639
https://git.flake.sh/modulatingforce/forcebot_rs/src/branch/main/src/core/identity.rs#L725


Possible Solution :

  • Address in Identity Module by adding into can_user_run() , even close to the beginning, validation involving the following pseudocode
let botVector = // result of pulling from a bot.config file
if botVector.contains(&usr) {
             return (
                Permissible::Block,
                ChangeResult::NoChange("Other Bots Cannot Run Commands".to_string()),
            );
} 
  • Likely around this area

https://git.flake.sh/modulatingforce/forcebot_rs/src/branch/main/src/core/identity.rs#L782


  • Need to also add unit test that asserts for
Permissible::Block,
ChangeResult::NoChange("Other Bots Cannot Run Commands".to_string()),
Relatively easy validation check . Should involve following - [x] Cmd Sender should be validated first if Bot or not - [x] Ideally a Configurable Shared Config file that could be adjusted if required in future , noting a list of known Bots --- Potentially Related Areas https://git.flake.sh/modulatingforce/forcebot_rs/src/branch/main/src/core/botinstance.rs#L277 https://git.flake.sh/modulatingforce/forcebot_rs/src/branch/main/src/core/botinstance.rs#L274 https://git.flake.sh/modulatingforce/forcebot_rs/src/branch/main/src/core/identity.rs#L639 https://git.flake.sh/modulatingforce/forcebot_rs/src/branch/main/src/core/identity.rs#L725 --- **Possible Solution :** - [x] Address in Identity Module by adding into `can_user_run()` , even close to the beginning, validation involving the following pseudocode ```rust let botVector = // result of pulling from a bot.config file if botVector.contains(&usr) { return ( Permissible::Block, ChangeResult::NoChange("Other Bots Cannot Run Commands".to_string()), ); } ``` - Likely around this area https://git.flake.sh/modulatingforce/forcebot_rs/src/branch/main/src/core/identity.rs#L782 --- - [x] Need to also add unit test that asserts for ``` Permissible::Block, ChangeResult::NoChange("Other Bots Cannot Run Commands".to_string()), ```
modulatingforce added the
Kind/Enhancement
Priority
Low
labels 2024-03-20 17:39:00 -04:00
Author
Owner

For ease, and so we don't have to re-invent the wheel, we can use Environment Variables, but instead of defining the OtherBots variable in a .gitignore .env file , we can set the Environment variable via Cargo.toml system :

https://doc.rust-lang.org/cargo/reference/config.html

** This would make it so moving forward, if we need to add other bot names, we can go easily to the known Cargo.toml

Internal code on the BotVector should be similar to handling environment variables as normal

For ease, and so we don't have to re-invent the wheel, we can use Environment Variables, but instead of defining the `OtherBots` variable in a `.gitignore` `.env` file , we can set the Environment variable via `Cargo.toml` system : https://doc.rust-lang.org/cargo/reference/config.html ** This would make it so moving forward, if we need to add other bot names, we can go easily to the known `Cargo.toml` Internal code on the `BotVector` should be similar to handling environment variables as normal
modulatingforce self-assigned this 2024-03-20 18:21:20 -04:00
modulatingforce added 1 commit 2024-03-20 19:08:09 -04:00
other bots cant run botcommands
All checks were successful
ci/woodpecker/pr/cargo-checks Pipeline was successful
e22e755bf5
modulatingforce added 1 commit 2024-03-20 19:26:11 -04:00
otherbots unit test
All checks were successful
ci/woodpecker/pr/cargo-checks Pipeline was successful
e86fa4884b
modulatingforce changed title from WIP: Prevent Bots from running BotCommands to Prevent Bots from running BotCommands 2024-03-20 19:28:13 -04:00
modulatingforce reviewed 2024-03-20 19:55:44 -04:00
modulatingforce left a comment
Author
Owner

Someone check this please

Someone check this please
@ -0,0 +1,4 @@
[env]
# Based on https://doc.rust-lang.org/cargo/reference/config.html
OtherBots = "Supibot,buttsbot,PotatBotat,StreamElements"
Author
Owner

Beep Boop testing a Review from Code?

Beep Boop testing a Review from Code?
Author
Owner

blorp blorp blorp blorp blorp blorp

blorp blorp blorp blorp blorp blorp
modulatingforce marked this conversation as resolved
modulatingforce merged commit 7efb679b06 into main 2024-03-20 19:58:26 -04:00
modulatingforce deleted branch Cmds_Cannot_Be_Ran_by_Bots 2024-03-20 19:58:26 -04:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: modulatingforce/forcebot_rs#36
No description provided.