Monarchz3ro / Silver

A unix inspired terminal mockup that is definitely not an emulator.
GNU General Public License v3.0
2 stars 2 forks source link

figure out a whitelist #14

Open Monarchz3ro opened 7 months ago

Monarchz3ro commented 7 months ago

right now, the way things work, the commands loader will on purpose skip any module that has any import statement within itself now. figure out a whitelist for modules that are "safe" for the player to load stuff like json or numpy

  1. NO modules that allow a player to cheese the game, for example, os.remove(path/to/victim/computer) -> disallow os
  2. NO modules that want the player to connect to the internet response = requests.get("www.myasshurts.com") -> disallow requests

that'll be that, i think. unless you can think of more criteria

OcelotWalrus commented 7 months ago

Maybe just, when running commands, check if they've the x permission (executable) in the ecosystem.json file permission and if yes, let the player run it.

Because making a whitelist would be a good idea, but the player could always change it anyway.

OcelotWalrus commented 7 months ago

By the way, there's a way to load external scripts way easier than the way you do it. I could change it in my PR if you'd like.

Monarchz3ro commented 7 months ago

Because making a whitelist would be a good idea, but the player could always change it anyway.

The player can change every single aspect of the shell environment because it is open source. They can simply create a nuke script that targets the exact absolute path to the NPC computer and shutil.rmtree() it. This is not the problem.

There is an intended route for the player to take, i.e, never touching anything outside of the current root directory. Because if they do not have the permissions to x a script they can simply go to the ecosystem.json file and change permissions there.

The player at every point has the freedom to mess with the game, and at that point, whatever they do is something I have chosen to completely ignore. All modification above the root folder is not intended and counts as cheating. Cheating has negative connotation, but I want to give that ability to players who think the way I handle things is too hard for them. There is an intended route, and a route where you simply look at the passwords in the json file.

Ah, by the way, if you are wondering how I intend to have the player computer (PathOS) interact with other computers, they will have their own filesystems that are essentially clones of the player's kernel folders. And there will be a networking module to ensure everything sticks together.

I haven't had much time to make a guide. I have art commissions whose deadlines are creeping up very soon and I must finish them, and my exams are inching closer. But I will make one.

Monarchz3ro commented 7 months ago

By the way, there's a way to load external scripts way easier than the way you do it. I could change it in my PR if you'd like.

Sure! Show me how.

OcelotWalrus commented 7 months ago

Makes sense to me now that you've explained ;)

OcelotWalrus commented 7 months ago

Also, I don't have any other ideas of modules to whitelist, but I'll tell you if I have any in the future.

OcelotWalrus commented 7 months ago

By the way, there's a way to load external scripts way easier than the way you do it. I could change it in my PR if you'd like.

Sure! Show me how.

Actually, the way I'd code it isn't really better; after thinking about it.

OcelotWalrus commented 7 months ago

Maybe a 'no import' rule is what's needed?

Monarchz3ro commented 7 months ago

a whitelist is better than a blacklist, because there are a LOT more modules we'd rather disallow than allow. not sure though - maybe this'll change in the future

OcelotWalrus commented 7 months ago

I think with open( statements should be also disabled in what you call 'modules'. Because it bypass the ecosystem permission. But that'd be apart from import checks.

Monarchz3ro commented 7 months ago

I was thinking of it, aye. I'll look into it.

OcelotWalrus commented 7 months ago

Talking about that, certain kernel functions should be 'locked', like the self.__user and self.root_dir ones for example. Something looks like this:


for i in locked_sys_var:
    if f"self.{i} =" in script:
      # skip script
Monarchz3ro commented 7 months ago

image

Monarchz3ro commented 7 months ago

two underscores before a variable's name lock it to the home script, i.e you can't read/write self.__user() outside of master.py

Monarchz3ro commented 7 months ago

image trying to print it directly throws a traceback

OcelotWalrus commented 7 months ago

Cool! Didn't know about that!

Monarchz3ro commented 7 months ago

yeah, i intend to lockdown every critical variable in master.py eventually