예제 #1
0
 def test_null(self):
     """Anything maybe using C strings MIGHT screw up ASCII NUL
     """
     assert scary(b"\0")
     assert scary(b"\0b")
     assert scary(b"a\0b")
     assert scary(b"a\0")
예제 #2
0
    def test_empty(self):
        """Empty variables can combine in surprising ways in shell

        and occur in a huge number of ways, intentional or not.
        So this is one of the first things to check.
        """
        assert scary(b'')
예제 #3
0
 def test_question_mark(self):
     assert scary(b'?')
예제 #4
0
 def test_variable_expansion(self):
     """prevent second-pass substitution of variable etc.
     """
     assert scary(b'$HOME')
예제 #5
0
 def test_star(self):
     assert scary(b'*')
예제 #6
0
 def test_hyphen(self):
     assert not scary(b"/home/user/ve-place")
예제 #7
0
 def test_comma(self):
     assert not scary(b"/home/user/python,ruby/virtualenvs")
예제 #8
0
 def test_background(self):
     assert scary(b"sleep 10 &")
예제 #9
0
 def test_normal(self):
     assert not scary(b"/home/user/whatever")
     assert not scary(b"/opt/weird/user/whatever")
     assert not scary(b"/foo")
예제 #10
0
 def test_here(self):
     assert scary(b"<<<")
     assert scary(b">>>")
예제 #11
0
 def test_or(self):
     assert scary(b"foo ||")
예제 #12
0
 def test_leading_hyphen(self):
     """prevent passing switches (e.g. for find) instead of dir
     """
     assert scary(b"-delete")
     assert scary(b"--delete")
예제 #13
0
 def test_root(self):
     """Using bare root seems inherently wrong
     """
     assert scary(b"/")
     assert scary(b"C:")
     assert scary(b"C:\\")
예제 #14
0
 def test_trailing_backslash(self):
     """prevent making outside char literal or continuing line
     """
     assert len("\\") == 1
     assert scary(b"prefix\\")
예제 #15
0
 def test_leading_single_quote(self):
     """prevent a less obvious way of messing with completion scripts
     """
     assert scary(b"' 'seems bad")
     assert scary(b"'")
예제 #16
0
 def test_variable_expansion_with_slash_and_suffix(self):
     """suffix doesn't fool us either
     """
     assert scary(b'/${HOME}/bar')
예제 #17
0
 def test_variable_expansion_with_slash(self):
     """leading slash doesn't fool us
     """
     assert scary(b'/${HOME}')
예제 #18
0
 def test_variable_expansion_with_braces(self):
     """also with braces style
     """
     assert scary(b'${HOME}')
예제 #19
0
 def test_semicolon(self):
     assert scary(b";")
예제 #20
0
 def test_newline(self):
     """shell can easily mess up newlines
     """
     assert scary(b"/foo\nbar")
     assert scary(b"/foo\n/bar")
예제 #21
0
 def test_and(self):
     assert scary(b"foo &&")
예제 #22
0
 def test_comment(self):
     """Don't want to ignore to end of shell line
     """
     assert scary(b'#foo')
     assert scary(b'stuff  # foo')
예제 #23
0
 def test_pipeline(self):
     assert scary(b"| bar")
예제 #24
0
 def test_arithmetic_expansion(self):
     assert scary(b'$(( 2 + 2 ))')
예제 #25
0
 def test_underscore(self):
     assert not scary(b"/home/user/ve_place")
예제 #26
0
 def test_integer_expansion(self):
     assert scary(b'$[ 2 + 2 ]')
예제 #27
0
 def test_space(self):
     assert not scary(b"/home/user/ve place")
예제 #28
0
 def test_lt(self):
     assert scary(b'<foo')
예제 #29
0
 def test_period(self):
     assert not scary(b"/home/user/.virtualenvs")
예제 #30
0
 def test_gt(self):
     assert scary(b'>foo')