[PYTHON] Check in advance what happens when you execute the command

Overview

Try using a Python tool maybe that allows you to see what happens when you execute a command.

It seems that you can check in advance about file operations such as file creation, deletion, movement, permission change by command execution 01.png

** Precautions **

That being said, maybe should :warning: NEVER :warning: be used to run untrusted code on a system you care about!
A process running under maybe can still do serious damage to your system because only a handful of syscalls are blocked.
Currently, maybe is best thought of as an (alpha-quality) "what exactly will this command I typed myself do?" tool.

Installation procedure

Install with pip

# pip install maybe

how to use maybe

Just add maybe before executing the command

$ maybe COMMAND [ARGUMENT]...

Try using

$ ls
file1  file2  file3

** Delete file **

$ maybe rm -f ./*
maybe has prevented rm -f ./file1 ./file2 ./file3 from performing 3 file system operations:

  delete /home/*******/test/file1
  delete /home/*******/test/file2
  delete /home/*******/test/file3

Do you want to rerun rm -f ./file1 ./file2 ./file3 and permit these operations? [y/N] y
$

Asks if you really want to do it

** Add directory / file **

$ maybe mkdir test ;maybe touch test/file1
maybe has prevented mkdir test from performing 1 file system operations:

  create directory /home/*******/test/test

Do you want to rerun mkdir test and permit these operations? [y/N] y
maybe has prevented touch test/file1 from performing 1 file system operations:

  create file /home/*******/test/test/file1

Do you want to rerun touch test/file1 and permit these operations? [y/N] y

** Starting a daemon **

# maybe /etc/init.d/docker start
Starting docker:
maybe has prevented /etc/init.d/docker start from performing 26 file system operations:

  write 33 bytes to /var/log/docker
  create file /root/nohup.out
  write 7 bytes to /var/log/docker
  write 35 bytes to /var/log/docker
  write 1 bytes to /var/log/docker
  create file /var/run/docker.pid
  write 4 bytes to /var/run/docker.pid
  write 91 bytes to /root/nohup.out
  write 1 bytes to /root/nohup.out
  write 1 bytes to /root/nohup.out
  write 1 bytes to /root/nohup.out
  write 1 bytes to /root/nohup.out
  write 1 bytes to /root/nohup.out
  write 1 bytes to /root/nohup.out
  write 1 bytes to /root/nohup.out
  write 1 bytes to /root/nohup.out
  write 1 bytes to /root/nohup.out
  write 1 bytes to /root/nohup.out
  write 5 bytes to /root/nohup.out
  write 1 bytes to /root/nohup.out
  write 7 bytes to /root/nohup.out
  write 6 bytes to /root/nohup.out
  write 7 bytes to /root/nohup.out
  write 1 bytes to /root/nohup.out
  write 1 bytes to /root/nohup.out
  write 1 bytes to /root/nohup.out

Do you want to rerun /etc/init.d/docker start and permit these operations? [y/N]

Recommended Posts

Check in advance what happens when you execute the command
Animate what happens in frequency space when the Nyquist frequency is exceeded
When you make a mistake in the directory where you execute `pipenv install`
[Question] What happens when I use% in python?
[Python] What to check when you get a Unicode Decode Error in Django
When the variable name conflicts with the Devaga command in pdb
Execute external command in python
Master the type in Python? (When should type check be done)
[AWS] What to do when the ping command causes a "timeout"
[Subprocess] When you want to execute another Python program in Python code
What to do if you can't use the trash in Lubuntu 18.04.
What to do when you get "I can't see the site !!!!"
What to do when the value type is ambiguous in Python?
What happens when I change the hyperparameters of SVM (RBF kernel)?
Check the behavior when assigning Python
In the python command python points to python3.8
Check the data summary in CASTable
When the node disappears in rqt_graph
What to do when the result downloaded via scrapy is in English
How to hide the command prompt when running python in visual studio 2015
What to do when the warning "The environment is in consistent ..." appears in the Anaconda environment
What happens if you do "import A, B as C" in Python?
If you get a no attribute error in boto3, check the version
When you can't call base.html in Django
Check the behavior of destructor in Python
Behavior when returning in the with block
Learn the design pattern "Command" in Python
Check if the URL exists in Python
What is "mahjong" in the Python library? ??
Notify Slack when the linux command finishes
When the target is Ubuntu 16.04 in Ansible
What happens when Ikura speaks your words?
Use the command previously entered in IDLE
Execute the COPY command using python's Psycopg
When the previous graph remains in Seaborn
You search commandlinefu on the command line
What I did when I got stuck in the time limit with lambda python
Implement the ability to reserve what happens regularly in your Django Todo list
A memorandum of how to execute the! Sudo magic command in Jupyter Notebook
The first thing to check when a No Reverse Match occurs in Django
What to do when the graph does not appear in jupyter (ipython) notebook
What happens to the access log when the website is automatically accessed by selenium-webdriver