Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/ZackeryRSmith/cval into main
Browse files Browse the repository at this point in the history
  • Loading branch information
ZackeryRSmith committed Feb 15, 2022
2 parents 7c09479 + 5c4f59b commit b2bd942
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</div>

# Installation
I know many people don't care about the motives behind a program. I have put the installation at the top for this reason
I know many people don't care about the motives behind a program, so I have put the installation at the top.

#### Unix and Mac
```shell
Expand Down Expand Up @@ -50,7 +50,7 @@ cval(source='__import__("os")', modules=False)

###### Output:
```text
cval.IllegalSource: Cval panicked due to an illegal module import in source
cval.IllegalSource: Cval panicked due to an illegal module import in source!
```

##### Allow certain modules
Expand All @@ -75,24 +75,27 @@ cval(source='print("Hello, World!")', calls=False, allowed_calls=["print"])

##### Block global variables
```python
password = "1234"
foo = "bar"
# You may also add "global foo". Due to the current scope we don't need to though

cval(source="password", globals=globals(), gscope=False)
def foobar():
cval(source="foo", globals=globals(), gscope=False) # Will not be able to access "foo"
```

###### Output:
```text
cval.SuspiciousSource: Cval found global variable "password" in the source, killing for safety
cval.SuspiciousSource: Cval found global variable "password" in the source, killing for safety!
```

##### Block local variables
```python
password = "1234"

cval(source='password', locals=locals(), lscope=False)
def foo():
bar = "foobar"

cval(source='bar', locals=locals(), lscope=False) # Will not be able to access "bar"
```

###### Output:
```text
Cval found local variable "password" in the source, killing for safety
Cval found local variable "password" in the source, killing for safety!
```

0 comments on commit b2bd942

Please sign in to comment.