Building and breaking a Python sandbox

Size: px
Start display at page:

Download "Building and breaking a Python sandbox"

Transcription

1 Building and breaking a Python sandbox

2 Director

3 Why? Learning a language Providing a hosted scratch pad Distributed computation Inspecting running processes safely

4 Examples in the wild Seattle s peer-to-peer computing network Google App Engine s Python shell Codecademy s empythoned CheckIO.org s online coding game

5

6 Building a sandbox Language-level sandboxing (pysandbox) OS-level sandboxing (PyPy s sandbox)

7 Question: How do we execute arbitrary code?

8 How do we execute arbitrary code? eval: compiles and evaluates expressions >>> eval("1 + 2") 3 exec: compiles and evaluates statements >>> exec "print 'Hello world'" Hello world

9 sandbox.py class Sandbox(object): def execute(self, code_string): exec code_string

10 test_sandbox.py from sandbox import Sandbox s = Sandbox() code = """ print "Hello world!" """ s.execute(code)

11 from sandbox import Sandbox s = Sandbox() code = """ print "Hello world!" """ s.execute(code) $ python test_sandbox.py Hello world!

12 What should we disallow?

13 What should we disallow? Resource exhaustion Information disclosure Running unexpected services Disabling/quitting/erroring out of the sandbox

14 from sandbox import Sandbox s = Sandbox() code = """ file("test.txt", "w").write("kaboom!\\n") """ s.execute(code)

15 >>> builtins. dict.keys() ['bytearray', 'IndexError', 'all', 'help', 'vars', 'SyntaxError', 'unicode', 'UnicodeDecodeError', 'memoryview', 'isinstance', 'copyright', 'NameError', 'BytesWarning', 'dict', 'input', 'oct', 'bin', 'SystemExit', 'StandardError', 'format', 'repr', 'sorted', 'False', 'RuntimeWarning', 'list', 'iter', 'reload', 'Warning', ' package ', 'round', 'dir', 'cmp', 'set', 'bytes', 'reduce', 'intern', 'issubclass', 'Ellipsis', 'EOFError', 'locals', 'BufferError', 'slice', 'FloatingPointError', 'sum', 'getattr', 'abs', 'exit', 'print', 'True', 'FutureWarning', 'ImportWarning', 'None', 'hash', 'ReferenceError', 'len', 'credits', 'frozenset', ' name ', 'ord', 'super', '_', 'TypeError', 'license', 'KeyboardInterrupt', 'UserWarning', 'filter', 'range', 'staticmethod', 'SystemError', 'BaseException', 'pow', 'RuntimeError', 'float', 'MemoryError', 'StopIteration', 'globals', 'divmod', 'enumerate', 'apply', 'LookupError', 'open', 'quit', 'basestring', 'UnicodeError', 'zip', 'hex', 'long', 'next', 'ImportError', 'chr', 'xrange', 'type', ' doc ', 'Exception', 'tuple', 'UnicodeTranslateError', 'reversed', 'UnicodeEncodeError', 'IOError', 'hasattr', 'delattr', 'setattr', 'raw_input', 'SyntaxWarning', 'compile', 'ArithmeticError', 'str', 'property', 'GeneratorExit', 'int', ' import ', 'KeyError', 'coerce', 'PendingDeprecationWarning', 'file', 'EnvironmentError', 'unichr', 'id', 'OSError', 'DeprecationWarning', 'min', 'UnicodeWarning', 'execfile', 'any', 'complex', 'bool', 'ValueError', 'NotImplemented', 'map', 'buffer', 'max', 'object', 'TabError', 'callable', 'ZeroDivisionError', 'eval', ' debug ', 'IndentationError', 'AssertionError', 'classmethod', 'UnboundLocalError', 'NotImplementedError', 'AttributeError', 'OverflowError']

16 >>> builtins. dict.keys() ['bytearray', 'IndexError', 'all', 'help', 'vars', 'SyntaxError', 'unicode', 'UnicodeDecodeError', 'memoryview', 'isinstance', 'copyright', 'NameError', 'BytesWarning', 'dict', 'input', 'oct', 'bin', 'SystemExit', 'StandardError', 'format', 'repr', 'sorted', 'False', 'RuntimeWarning', 'list', 'iter', 'reload', 'Warning', ' package ', 'round', 'dir', 'cmp', 'set', 'bytes', 'reduce', 'intern', 'issubclass', 'Ellipsis', 'EOFError', 'locals', 'BufferError', 'slice', 'FloatingPointError', 'sum', 'getattr', 'abs', 'exit', 'print', 'True', 'FutureWarning', 'ImportWarning', 'None', 'hash', 'ReferenceError', 'len', 'credits', 'frozenset', ' name ', 'ord', 'super', '_', 'TypeError', 'license', 'KeyboardInterrupt', 'UserWarning', 'filter', 'range', 'staticmethod', 'SystemError', 'BaseException', 'pow', 'RuntimeError', 'float', 'MemoryError', 'StopIteration', 'globals', 'divmod', 'enumerate', 'apply', 'LookupError', 'open', 'quit', 'basestring', 'UnicodeError', 'zip', 'hex', 'long', 'next', 'ImportError', 'chr', 'xrange', 'type', ' doc ', 'Exception', 'tuple', 'UnicodeTranslateError', 'reversed', 'UnicodeEncodeError', 'IOError', 'hasattr', 'delattr', 'setattr', 'raw_input', 'SyntaxWarning', 'compile', 'ArithmeticError', 'str', 'property', 'GeneratorExit', 'int', ' import ', 'KeyError', 'coerce', 'PendingDeprecationWarning', 'file', 'EnvironmentError', 'unichr', 'id', 'OSError', 'DeprecationWarning', 'min', 'UnicodeWarning', 'execfile', 'any', 'complex', 'bool', 'ValueError', 'NotImplemented', 'map', 'buffer', 'max', 'object', 'TabError', 'callable', 'ZeroDivisionError', 'eval', ' debug ', 'IndentationError', 'AssertionError', 'classmethod', 'UnboundLocalError', 'NotImplementedError', 'AttributeError', 'OverflowError']

17 How do we disallow execution of problematic builtins?

18 Idea: keyword blacklist

19 Idea: keyword blacklist class Sandbox(object): def execute(self, code_string): keyword_blacklist = ["file", "open", "eval", "exec"] for keyword in keyword_blacklist: if keyword in code_string: raise ValueError("Blacklisted") exec code_string

20 Testing: keyword blacklist from sandbox import Sandbox s = Sandbox() code = """ file("test.txt", "w").write("kaboom!\\n") """ s.execute(code)

21 Testing: keyword blacklist from sandbox import Sandbox s = Sandbox() code = """ file("test.txt", "w").write("kaboom!\\n") """ s.execute(code) $ python test_sandbox.py Traceback (most recent call last): File "test_sandbox.py", line 11, in <module> s.execute(code) File "/Users/jesstess/Desktop/sandbox/ sandbox.py", line 86, in execute raise ValueError("Blacklisted") ValueError: Blacklisted

22 How can we get around a keyword blacklist?

23 Circumvention idea: encryption func = builtins ["file"] func("test.txt", "w").write("kaboom!\n")

24 Circumvention idea: encryption func = builtins ["file"] func("test.txt", "w").write("kaboom!\n") func = builtins ["svyr".decode("rot13")] func("test.txt", "w").write("kaboom!\n")

25 Testing: keyword blacklist from sandbox import Sandbox s = Sandbox() code = """ func = builtins ["svyr".decode("rot13")] func("test.txt", "w").write("kaboom!\\n") """ s.execute(code) Kaboom

26 Observation: if I can get a reference to something bad, I can invoke it.

27 How can we remove all references to problematic builtins?

28 Idea: builtins whitelist

29 builtins_whitelist = set(( # exceptions 'ArithmeticError', 'AssertionError', 'AttributeError',... # constants 'False', 'None', 'True',... # types 'basestring', 'bytearray', 'bytes', 'complex', 'dict',... # functions ' import ', 'abs', 'all', 'any', 'apply', 'bin', 'bool',... # block: eval, execfile, file, quit, exit, reload, etc. ))

30 import sys main = sys.modules[" main "]. dict orig_builtins = main[" builtins "]. dict builtins_whitelist = set((... )) for builtin in orig_builtins.keys(): if builtin not in builtins_whitelist: del orig_builtins[builtin]

31 Testing: builtins whitelist from sandbox import Sandbox s = Sandbox() code = """ file("test.txt", "w").write("kaboom!\\n") """ s.execute(code)

32 Testing: builtins whitelist from sandbox import Sandbox s = Sandbox() code = """ file("test.txt", "w").write("kaboom!\\n") """ s.execute(code) $ python test_sandbox.py Traceback (most recent call last): File "test_sandbox.py", line 9, in <module> s.execute(code)... File "<string>", line 2, in <module> NameError: name 'file' is not defined

33 Circumvention idea: import something dangerous

34 Testing: builtins whitelist from sandbox import Sandbox s = Sandbox() code = """ import os fd = os.open("test.txt", os.o_creat os.o_wronly) os.write(fd, "Kaboom!\\n") """ s.execute(code) Kaboom

35 How do we disallow problematic imports?

36 Idea: import whitelist

37 Idea: import whitelist How does importing a module work in Python? >>> importer = builtins. dict.get(" import ") >>> os = importer("os") >>> os <module 'os' from '/Library/Frameworks/ Python.framework/Versions/2.7/lib/python2.7/os.pyc'> >>> os.getcwd() '/Users/jesstess/Desktop/sandbox'

38 Idea: import whitelist What is the expected function signature for the importer? >>> help( builtins. dict [" import "]) import (...) import (name, globals={}, locals={}, fromlist=[], level=-1) -> module

39 Idea: import whitelist Cool, let s write our own importer >>> def my_importer(module_name, globals={},... locals={}, fromlist=[],... level=-1):... print "Using my importer!"... return import (module_name, globals,... locals, fromlist, level)... >>> os = my_importer("os") Using my importer! >>> os.getcwd() '/Users/jesstess/Desktop/sandbox'

40 def _safe_import( import, module_whitelist): def safe_import(module_name, globals={}, locals={}, fromlist=[], level=-1):! if module_name in module_whitelist: return import (module_name,!!!!!!!!!!!! globals, locals, fromlist, level) else: raise ImportError( "Blocked import of %s" ( module_name,)) return safe_import

41 import sys main = sys.modules[" main "]. dict orig_builtins = main[" builtins "]. dict for builtin in orig_builtins.keys(): if builtin not in builtins_whitelist: del original_builtins[builtin] safe_modules = ["string", "re"] orig_builtins[" import "] = _safe_import( import, safe_modules)

42 Testing: import whitelist from sandbox import Sandbox s = Sandbox() code = """ import os fd = os.open("test.txt", os.o_creat os.o_wronly) os.write(fd, "Kaboom!\\n") """ s.execute(code)

43 Testing: import whitelist from sandbox import Sandbox s = Sandbox() code = """ import os fd = os.open("test.txt", os.o_creat os.o_wronly) os.write(fd, "Kaboom!\\n") """ s.execute(code) $ python test_sandbox.py Traceback (most recent call last): File "test_sandbox.py", line 11, in <module>... raise ImportError("Blocked import of %s" % (module_name,)) ImportError: Blocked import of os

44 Circumvention idea: modifying builtins

45 Idea: make builtins read-only

46 How can we make an object read-only in Python?

47 class ReadOnlyBuiltins(dict): def delitem (self, key): ValueError("Read-only!") def pop(self, key, default=none): ValueError("Read-only!") def popitem(self): ValueError("Read-only!")... def setdefault(self, key, value): ValueError("Read-only!") def setitem (self, key, value): ValueError("Read-only!") def update(self, dict, **kw): ValueError("Read-only!")

48 main = sys.modules[" main "]. dict orig_builtins = main[" builtins "]. dict for builtin in orig_builtins.keys(): if builtin not in builtins_whitelist: del original_builtins[builtin] safe_modules = ["string", "re"] orig_builtins[" import "] = _safe_import( import, safe_modules) safe_builtins = ReadOnlyBuiltins( original_builtins) main[" builtins "] = safe_builtins

49 Observation redux: if I can get a reference to something bad, I can invoke it.

50 Circumvention idea: exploiting the inheritance hierarchy

51 What can we find out about an object s base classes? >>> dir([]) [' add ', ' class ', ' contains ', ' delattr ', ' delitem ', ' delslice ', ' doc ', ' eq ', ' format ', ' ge ',...] >>> []. class <type 'list'>

52 What can we find out about an object s base classes? list subclasses object >>> []. class <type 'list'> >>> []. class. bases (<type 'object'>,) >>> []. class. bases [0] <type 'object'>

53 What can we find out about an object s subclasses? >>> []. class. subclasses () [] >>> int. subclasses () [<type 'bool'>] >>> basestring. subclasses () [<type 'str'>, <type 'unicode'>] subclasses of basestring

54 >>> []. class. bases [0]. subclasses () [<type 'type'>, <type 'weakref'>, <type 'weakcallableproxy'>, <type 'weakproxy'>, <type 'int'>, <type 'basestring'>, <type 'bytearray'>, <type 'list'>, <type 'NoneType'>, <type 'NotImplementedType'>, <type 'traceback'>, <type 'super'>, <type 'xrange'>, <type 'dict'>, <type 'set'>, <type 'slice'>, <type 'staticmethod'>, <type 'complex'>, <type 'float'>, <type 'buffer'>, <type 'long'>, <type 'frozenset'>, <type 'property'>, <type 'memoryview'>, <type 'tuple'>, <type 'enumerate'>, <type 'reversed'>, <type 'code'>, <type 'frame'>, <type 'builtin_function_or_method'>, <type 'instancemethod'>, <type 'function'>, <type 'classobj'>, <type 'dictproxy'>, <type 'generator'>, <type 'getset_descriptor'>, <type 'wrapper_descriptor'>, <type 'instance'>, <type 'ellipsis'>, <type 'member_descriptor'>, <type 'file'>, <type 'PyCapsule'>, <type 'cell'>, <type 'callable-iterator'>, <type 'iterator'>, <type 'sys.long_info'>, <type 'sys.float_info'>, <type 'EncodingMap'>, <type 'fieldnameiterator'>, <type 'formatteriterator'>, <type 'sys.version_info'>, <type 'sys.flags'>, <type 'exceptions.baseexception'>, <type 'module'>, <type 'imp.nullimporter'>, <type 'zipimport.zipimporter'>, <type 'posix.stat_result'>, <type 'posix.statvfs_result'>, <class 'warnings.warningmessage'>, <class 'warnings.catch_warnings'>, <class '_weakrefset._iterationguard'>, <class '_weakrefset.weakset'>, <class '_abcoll.hashable'>, <type 'classmethod'>, <class '_abcoll.iterable'>, <class '_abcoll.sized'>, <class '_abcoll.container'>, <class '_abcoll.callable'>, <class 'site._printer'>, <class 'site._helper'>, <type '_sre.sre_pattern'>, <type '_sre.sre_match'>, <type '_sre.sre_scanner'>, <class 'site.quitter'>, <class 'codecs.incrementalencoder'>, <class 'codecs.incrementaldecoder'>, <class 'string.template'>, <class 'string.formatter'>, <type 'operator.itemgetter'>, <type 'operator.attrgetter'>, <type 'operator.methodcaller'>, <type 'collections.deque'>, <type 'deque_iterator'>, <type 'deque_reverse_iterator'>, <type 'itertools.combinations'>, <type 'itertools.combinations_with_replacement'>, <type 'itertools.cycle'>, <type 'itertools.dropwhile'>, <type 'itertools.takewhile'>, <type 'itertools.islice'>, <type 'itertools.starmap'>, <type 'itertools.imap'>, <type 'itertools.chain'>, <type 'itertools.compress'>, <type 'itertools.ifilter'>, <type 'itertools.ifilterfalse'>, <type 'itertools.count'>, <type 'itertools.izip'>, <type 'itertools.izip_longest'>, <type 'itertools.permutations'>, <type 'itertools.product'>, <type 'itertools.repeat'>, <type 'itertools.groupby'>, <type 'itertools.tee_dataobject'>, <type 'itertools.tee'>, <type 'itertools._grouper'>, <type '_thread._localdummy'>, <type 'thread._local'>, <type 'thread.lock'>, <class 'sandbox.protection'>, <type 'resource.struct_rusage'>, <class 'sandbox.config.sandboxconfig'>, <class 'sandbox.proxy.readonlysequence'>, <class 'sandbox.sandbox_class.sandbox'>, <class 'sandbox.restorable_dict.restorabledict'>] >>> []. class. bases (<type 'object'>,) >>> []. class. bases [0] <type 'object'> All of the subclasses of object!

55 >>> []. class. bases (<type 'object'>,) >>> []. class. bases [0] <type 'object'> >>> obj_class = []. class. bases [0] >>> for c in obj_class. subclasses ():... print c. name... wrapper_descriptor instance ellipsis member_descriptor file PyCapsule cell callable-iterator iterator...

56 >>> []. class. bases (<type 'object'>,) >>> []. class. bases [0] <type 'object'> >>> obj_class = []. class. bases [0] >>> for c in obj_class. subclasses ():... print c. name... wrapper_descriptor instance ellipsis member_descriptor file PyCapsule cell!!! callable-iterator iterator...

57 from sandbox import Sandbox s = Sandbox() Testing: read-only builtins code = """ obj_class = []. class. bases [0] obj_subclasses = dict((elt. name, elt) for \ elt in obj_class. subclasses ()) func = obj_subclasses["file"] func("text.txt", "w").write("kaboom!\\n") """ s.execute(code) Kaboom

58 Idea: don t expose dangerous implementation details

59 Let s delete bases and subclasses >>> type. bases (<type 'object'>,) >>> del type. bases

60 Let s delete bases and subclasses >>> type. bases (<type 'object'>,) >>> del type. bases Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: can't set attributes of builtin/extension type 'type' Imposed by the underlying C implementation!

61 Let s delete bases and subclasses cpython.py from ctypes import pythonapi, POINTER, py_object _get_dict = pythonapi._pyobject_getdictptr _get_dict.restype = POINTER(py_object) _get_dict.argtypes = [py_object] del pythonapi, POINTER, py_object def dictionary_of(ob): dptr = _get_dict(ob) return dptr.contents.value

62 from cpython import dictionary_of main = sys.modules[" main "]. dict... safe_builtins = ReadOnlyBuiltins( original_builtins) main[" builtins "] = safe_builtins type_dict = dictionary_of(type) del type_dict[" bases "] del type_dict[" subclasses "]

63 Circumvention idea: would a function by any other name smell as sweet?

64 >>> def foo():... print "Meow"... >>> dir(foo) [' call ', ' class ', ' closure ', ' code ', ' defaults ', ' delattr ', ' dict ', ' doc ', ' format ', ' get ', ' getattribute ', ' globals ', ' hash ', ' init ', ' module ', ' name ', ' new ', ' reduce ', ' reduce_ex ', ' repr ', ' setattr ', ' sizeof ', ' str ', ' subclasshook ', 'func_closure', 'func_code', 'func_defaults', 'func_dict', 'func_doc', 'func_globals', 'func_name']

65 >>> def foo():... print "Meow"... >>> dir(foo) [' call ', ' class ', ' closure ', ' code ', ' defaults ', ' delattr ', ' dict ', ' doc ', ' format ', ' get ', ' getattribute ', ' globals ', ' hash ', ' init ', ' module ', ' name ', ' new ', ' reduce ', ' reduce_ex ', ' repr ', ' setattr ', ' sizeof ', ' str ', ' subclasshook ', 'func_closure', 'func_code', 'func_defaults', 'func_dict', 'func_doc', 'func_globals', 'func_name']???

66 >>> foo.func_code <code object foo at 0x100509d30, file "<stdin>", line 1> >>> dir(foo.func_code) [' class ', ' cmp ', ' delattr ', ' doc ', ' eq ', ' format ', ' ge ', ' getattribute ', ' gt ', ' hash ', ' init ', ' le ', ' lt ', ' ne ', ' new ', ' reduce ', ' reduce_ex ', ' repr ', ' setattr ', ' sizeof ', ' str ', ' subclasshook ', 'co_argcount', 'co_cellvars', 'co_code', 'co_consts', 'co_filename', 'co_firstlineno', 'co_flags', 'co_freevars', 'co_lnotab', 'co_name', 'co_names', 'co_nlocals', 'co_stacksize', 'co_varnames'] >>> foo.func_code.co_code 'd\x01\x00ghd\x00\x00s'

67 >>> def foo():... print "Meow"... >>> def evil_function():... print "Kaboom!"... >>> foo() Meow >>> foo. setattr ("func_code", evil_function.func_code) >>> foo() Kaboom! Kaboom

68 Idea redux: don t expose dangerous implementation details

69 Delete func_code from cpython import dictionary_of from types import FunctionType... type_dict = dictionary_of(type) del type_dict[" bases "] del type_dict[" subclasses "] function_dict = dictionary_of(functiontype) del function_dict["func_code"]

70 Whew. Let s recap tactics: Keyword blacklist Builtins whitelist Import whitelist Making important objects read-only (builtins) Deleting problematic implementation details ( bases, subclasses, func_code) Deleting the ability to construct arbitrary code objects

71 We have run out of tricks! We ve implemented 80% of a full-fledged Python sandbox

72 builtins_whitelist = set(( # exceptions 'ArithmeticError', 'AssertionError', 'AttributeError', 'BufferError', 'BytesWarning', 'DeprecationWarning', 'EOFError', 'EnvironmentError', 'Exception', 'FloatingPointError','FutureWarning', 'GeneratorExit', 'IOError', 'ImportError', 'ImportWarning', 'IndentationError', 'IndexError', 'KeyError','LookupError', 'MemoryError', 'NameError', 'NotImplemented', 'NotImplementedError', 'OSError', 'OverflowError','PendingDeprecationWarning', 'ReferenceError', 'RuntimeError', 'RuntimeWarning', 'StandardError', 'StopIteration', 'SyntaxError', 'SyntaxWarning', 'SystemError', 'TabError', 'TypeError', 'UnboundLocalError', 'UnicodeDecodeError', 'UnicodeEncodeError','UnicodeError', 'UnicodeTranslateError', 'UnicodeWarning', # constants 'False', 'None', 'True', ' doc ', ' name ', ' package ', 'copyright', 'license', 'credits', # types 'basestring', 'bytearray', 'bytes', 'complex', 'dict', 'float', 'frozenset', 'int', 'list', 'long', 'object', 'set', 'str', 'tuple', 'unicode', # functions ' import ', 'abs', 'all', 'any', 'apply', 'bin', 'bool', 'buffer', 'callable', 'chr', 'classmethod', 'cmp', 'coerce', 'compile', 'delattr', 'dir', 'divmod', 'enumerate', 'filter', 'format', 'getattr', 'globals', 'hasattr', 'hash', 'hex', 'id', 'isinstance', 'issubclass', 'iter', 'len', 'locals', 'map', 'max', 'min', 'next', 'oct', 'ord', 'pow', 'print', 'property', 'range', 'reduce', 'repr', 'reversed', 'round', 'setattr', 'slice', 'sorted', 'staticmethod', 'sum', 'super', 'type', 'unichr', 'vars', 'xrange', 'zip', )) def _safe_import( import, module_whitelist): def safe_import(module_name, globals={}, locals={}, fromlist=[], level=-1): if module_name in module_whitelist: return import (module_name, globals, locals, fromlist, level) else: raise ImportError("Blocked import of %s" % (module_name,)) return safe_import builtins whitelist import whitelist class ReadOnlyBuiltins(dict): def clear(self): ValueError("Read-only!") def delitem (self, key): ValueError("Read-only!") def pop(self, key, default=none): ValueError("Read-only!") def popitem(self): ValueError("Read-only!") read-only builtins def setdefault(self, key, value):! ValueError("Read-only!") def setitem (self, key, value): ValueError("Read-only!") def update(self, dict, **kw): ValueError("Read-only!") class Sandbox(object): def init (self):! import sys! from types import FunctionType! from cpython import dictionary_of! original_builtins = sys.modules[" main "]. dict [" builtins "]. dict! for builtin in original_builtins.keys(): if builtin not in builtins_whitelist:!! del sys.modules[" main "]. dict [" builtins "]. dict [builtin] original_builtins[" import "] = _safe_import( import, ["string", "re"]) safe_builtins = ReadOnlyBuiltins(original_builtins) sys.modules[" main "]. dict [" builtins "] = safe_builtins! type_dict = dictionary_of(type)! del type_dict[" bases "]! del type_dict[" subclasses "] deleting bases, subclasses_, and func_code! function_dict = dictionary_of(functiontype)! del function_dict["func_code"] def execute(self, code_string):! exec code_string

73 Building a sandbox Language-level sandboxing (pysandbox) OS-level sandboxing (PyPy s sandbox)

74 What should we disallow? Resource exhaustion Information disclosure Running unexpected services Disabling/quitting/erroring out of the sandbox

75 Food for thought

76 Is this level of reflectiveness good or bad?

77 Do other languages have these sandboxing concerns?

78 If you were designing a new language, how would you do this?

79 Experiments How does an alternative Python implementation like PyPy handle these issues? How does the CPython interpreter compile and run bytecode? What does the Python stack look like? How do ctypes work? How can the operating system help provide a secure environment?

80 Bedtime reading The full pysandbox implementation: A retrospective on pysandbox s challenges: PyPy s sandbox implementation: How PythonAnywhere s sandbox works:

81 Thank you!

82 Thank you! Let s talk! O Reilly booth, 3pm

Computational Science and Engineering in Python

Computational Science and Engineering in Python Computational Science and Engineering in Python Hans Fangohr Engineering and the Environment University of Southampton United Kingdom [email protected] September 7, 2015 1 / 355 Outline I 1 Python prompt

More information

Introduction to Python Programming Course Notes. Phil Spector Department of Statistics, University of California Berkeley

Introduction to Python Programming Course Notes. Phil Spector Department of Statistics, University of California Berkeley Introduction to Python Programming Course Notes Phil Spector Department of Statistics, University of California Berkeley March 16, 2005 2 Contents 1 Introduction 7 1.1 What is Python?.........................

More information

Instruction Set Architecture of Mamba, a New Virtual Machine for Python

Instruction Set Architecture of Mamba, a New Virtual Machine for Python Instruction Set Architecture of Mamba, a New Virtual Machine for Python David Pereira and John Aycock Department of Computer Science University of Calgary 2500 University Drive N.W. Calgary, Alberta, Canada

More information

Self-review 9.3 What is PyUnit? PyUnit is the unit testing framework that comes as standard issue with the Python system.

Self-review 9.3 What is PyUnit? PyUnit is the unit testing framework that comes as standard issue with the Python system. Testing, Testing 9 Self-Review Questions Self-review 9.1 What is unit testing? It is testing the functions, classes and methods of our applications in order to ascertain whether there are bugs in the code.

More information

Software Tool Seminar WS1516 - Taming the Snake

Software Tool Seminar WS1516 - Taming the Snake Software Tool Seminar WS1516 - Taming the Snake November 4, 2015 1 Taming the Snake 1.1 Understanding how Python works in N simple steps (with N still growing) 1.2 Step 0. What this talk is about (and

More information

Python 2 and 3 compatibility testing via optional run-time type checking

Python 2 and 3 compatibility testing via optional run-time type checking Python 2 and 3 compatibility testing via optional run-time type checking Raoul-Gabriel Urma Work carried out during a Google internship & PhD https://github.com/google/pytypedecl Python 2 vs. Python 3

More information

Things you didn't know about Python

Things you didn't know about Python Things you didn't know about Python a presentation by Armin Ronacher for PyCon South Africa 2012 @mitsuhiko http://lucumr.pocoo.org/ Things you didn't know about Python might already know computers a presentation

More information

Google Apps Engine. G-Jacking AppEngine-based applications. Presented 30/05/2014. For HITB 2014 By Nicolas Collignon and Samir Megueddem

Google Apps Engine. G-Jacking AppEngine-based applications. Presented 30/05/2014. For HITB 2014 By Nicolas Collignon and Samir Megueddem Google Apps Engine G-Jacking AppEngine-based applications Presented 30/05/2014 For HITB 2014 By Nicolas Collignon and Samir Megueddem Introduction to GAE G-Jacking The code The infrastructure The sandbox

More information

Django & Python 3. Aymeric Augustin - @aymericaugustin. PyConFR - September 16th, 2012

Django & Python 3. Aymeric Augustin - @aymericaugustin. PyConFR - September 16th, 2012 Django & Python 3 Aymeric Augustin - @aymericaugustin PyConFR - September 16th, 2012 1 Python 3 is the future 2 Python 3 is the future present 3 Django wants a future 4 how? 5 porting strategies 3to2 single

More information

10 awesome features of Python that you can't use because you refuse to upgrade to Python 3

10 awesome features of Python that you can't use because you refuse to upgrade to Python 3 10 awesome features of Python that you can't use because you refuse to upgrade to Python 3 1 / 72 http://asmeurer.github.io/python3-presentation/slides.html#1 1/72 10 awesome features of Python that you

More information

Python Objects. Charles Severance www.pythonlearn.com. http://en.wikipedia.org/wiki/object-oriented_programming

Python Objects. Charles Severance www.pythonlearn.com. http://en.wikipedia.org/wiki/object-oriented_programming Python Objects Charles Severance www.pythonlearn.com http://en.wikipedia.org/wiki/object-oriented_programming Warning This lecture is very much about definitions and mechanics for objects This lecture

More information

A skip list container class in Python

A skip list container class in Python A skip list container class in Python Abstract An alternative to balanced trees John W. Shipman 2012-11-29 13:23 Describes a module in the Python programming language that implements a skip list, a data

More information

Python Loops and String Manipulation

Python Loops and String Manipulation WEEK TWO Python Loops and String Manipulation Last week, we showed you some basic Python programming and gave you some intriguing problems to solve. But it is hard to do anything really exciting until

More information

Obfuscation: know your enemy

Obfuscation: know your enemy Obfuscation: know your enemy Ninon EYROLLES [email protected] Serge GUELTON [email protected] Prelude Prelude Plan 1 Introduction What is obfuscation? 2 Control flow obfuscation 3 Data flow

More information

Analog Documentation. Release 0.3.4. Fabian Büchler

Analog Documentation. Release 0.3.4. Fabian Büchler Analog Documentation Release 0.3.4 Fabian Büchler April 01, 2014 Contents 1 Contents 3 1.1 Quickstart................................................ 3 1.2 Analog API................................................

More information

[1] Learned how to set up our computer for scripting with python et al. [3] Solved a simple data logistics problem using natural language/pseudocode.

[1] Learned how to set up our computer for scripting with python et al. [3] Solved a simple data logistics problem using natural language/pseudocode. Last time we... [1] Learned how to set up our computer for scripting with python et al. [2] Thought about breaking down a scripting problem into its constituent steps. [3] Solved a simple data logistics

More information

Introduction to Python

Introduction to Python Caltech/LEAD Summer 2012 Computer Science Lecture 2: July 10, 2012 Introduction to Python The Python shell Outline Python as a calculator Arithmetic expressions Operator precedence Variables and assignment

More information

CIS 192: Lecture 10 Web Development with Flask

CIS 192: Lecture 10 Web Development with Flask CIS 192: Lecture 10 Web Development with Flask Lili Dworkin University of Pennsylvania Last Week s Quiz req = requests.get("http://httpbin.org/get") 1. type(req.text) 2. type(req.json) 3. type(req.json())

More information

Introduction to Python for Text Analysis

Introduction to Python for Text Analysis Introduction to Python for Text Analysis Jennifer Pan Institute for Quantitative Social Science Harvard University (Political Science Methods Workshop, February 21 2014) *Much credit to Andy Hall and Learning

More information

Chapter 3 Writing Simple Programs. What Is Programming? Internet. Witin the web server we set lots and lots of requests which we need to respond to

Chapter 3 Writing Simple Programs. What Is Programming? Internet. Witin the web server we set lots and lots of requests which we need to respond to Chapter 3 Writing Simple Programs Charles Severance Unless otherwise noted, the content of this course material is licensed under a Creative Commons Attribution 3.0 License. http://creativecommons.org/licenses/by/3.0/.

More information

Introduction to Logging. Application Logging

Introduction to Logging. Application Logging Introduction to Logging David Beazley Copyright (C) 2008 http://www.dabeaz.com Note: This is a supplemental subject component to Dave's Python training classes. Details at: http://www.dabeaz.com/python.html

More information

Name Spaces. Introduction into Python Python 5: Classes, Exceptions, Generators and more. Classes: Example. Classes: Briefest Introduction

Name Spaces. Introduction into Python Python 5: Classes, Exceptions, Generators and more. Classes: Example. Classes: Briefest Introduction Name Spaces Introduction into Python Python 5: Classes, Exceptions, Generators and more Daniel Polani Concept: There are three different types of name spaces: 1. built-in names (such as abs()) 2. global

More information

Python Programming: An Introduction To Computer Science

Python Programming: An Introduction To Computer Science Python Programming: An Introduction To Computer Science Chapter 8 Booleans and Control Structures Python Programming, 2/e 1 Objectives æ To understand the concept of Boolean expressions and the bool data

More information

pyownet Documentation

pyownet Documentation pyownet Documentation Release 0.10.0 Stefano Miccoli March 30, 2016 Contents 1 Contents 3 1.1 Introduction............................................. 3 1.2 Installation..............................................

More information

The P3 Compiler: compiling Python to C++ to remove overhead

The P3 Compiler: compiling Python to C++ to remove overhead The P3 Compiler: compiling Python to C++ to remove overhead Jared Pochtar 1. Introduction Python is a powerful, modern language with many features that make it attractive to programmers. As a very high

More information

LEARNING TO PROGRAM WITH PYTHON. Richard L. Halterman

LEARNING TO PROGRAM WITH PYTHON. Richard L. Halterman LEARNING TO PROGRAM WITH PYTHON Richard L. Halterman Copyright 2011 Richard L. Halterman. All rights reserved. i Contents 1 The Context of Software Development 1 1.1 Software............................................

More information

Python for Test Automation i. Python for Test Automation

Python for Test Automation i. Python for Test Automation i Python for Test Automation ii Copyright 2011 Robert Zuber. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form, or by any means,

More information

Crash Dive into Python

Crash Dive into Python ECPE 170 University of the Pacific Crash Dive into Python 2 Lab Schedule Ac:vi:es Assignments Due Today Lab 8 Python Due by Oct 26 th 5:00am Endianness Lab 9 Tuesday Due by Nov 2 nd 5:00am Network programming

More information

Introduction to Python

Introduction to Python WEEK ONE Introduction to Python Python is such a simple language to learn that we can throw away the manual and start with an example. Traditionally, the first program to write in any programming language

More information

vmprof Documentation Release 0.1 Maciej Fijalkowski, Antonio Cuni, Sebastian Pawlus

vmprof Documentation Release 0.1 Maciej Fijalkowski, Antonio Cuni, Sebastian Pawlus vmprof Documentation Release 0.1 Maciej Fijalkowski, Antonio Cuni, Sebastian Pawlus January 23, 2016 Contents 1 Introduction 1 1.1 Requirements............................................... 1 1.2 Installation................................................

More information

Python Tutorial. Release 2.6.4. Guido van Rossum Fred L. Drake, Jr., editor. January 04, 2010. Python Software Foundation Email: docs@python.

Python Tutorial. Release 2.6.4. Guido van Rossum Fred L. Drake, Jr., editor. January 04, 2010. Python Software Foundation Email: docs@python. Python Tutorial Release 2.6.4 Guido van Rossum Fred L. Drake, Jr., editor January 04, 2010 Python Software Foundation Email: [email protected] CONTENTS 1 Whetting Your Appetite 3 2 Using the Python Interpreter

More information

Boolean Expressions, Conditions, Loops, and Enumerations. Precedence Rules (from highest to lowest priority)

Boolean Expressions, Conditions, Loops, and Enumerations. Precedence Rules (from highest to lowest priority) Boolean Expressions, Conditions, Loops, and Enumerations Relational Operators == // true if two values are equivalent!= // true if two values are not equivalent < // true if left value is less than the

More information

Getting Started with the Internet Communications Engine

Getting Started with the Internet Communications Engine Getting Started with the Internet Communications Engine David Vriezen April 7, 2014 Contents 1 Introduction 2 2 About Ice 2 2.1 Proxies................................. 2 3 Setting Up ICE 2 4 Slices 2

More information

Paraview scripting. Raffaele Ponzini [email protected] SuperComputing Applications and Innovation Department

Paraview scripting. Raffaele Ponzini r.ponzini@cineca.it SuperComputing Applications and Innovation Department Paraview scripting Raffaele Ponzini [email protected] SuperComputing Applications and Innovation Department OUTLINE Why scripting pvbatch and pvpython Macros Scripting using a tracefile Journaling in

More information

CRASH COURSE PYTHON. Het begint met een idee

CRASH COURSE PYTHON. Het begint met een idee CRASH COURSE PYTHON nr. Het begint met een idee This talk Not a programming course For data analysts, who want to learn Python For optimizers, who are fed up with Matlab 2 Python Scripting language expensive

More information

Exercise 4 Learning Python language fundamentals

Exercise 4 Learning Python language fundamentals Exercise 4 Learning Python language fundamentals Work with numbers Python can be used as a powerful calculator. Practicing math calculations in Python will help you not only perform these tasks, but also

More information

Are you already a Python programmer? Did you read the original Dive Into Python? Did you buy it

Are you already a Python programmer? Did you read the original Dive Into Python? Did you buy it CHAPTER -1. WHAT S NEW IN DIVE INTO PYTHON 3 Isn t this where we came in? Pink Floyd, The Wall -1.1. A.K.A. THE MINUS LEVEL Are you already a Python programmer? Did you read the original Dive Into Python?

More information

Programming Language Rankings. Lecture 15: Type Inference, polymorphism & Type Classes. Top Combined. Tiobe Index. CSC 131! Fall, 2014!

Programming Language Rankings. Lecture 15: Type Inference, polymorphism & Type Classes. Top Combined. Tiobe Index. CSC 131! Fall, 2014! Programming Language Rankings Lecture 15: Type Inference, polymorphism & Type Classes CSC 131 Fall, 2014 Kim Bruce Top Combined Tiobe Index 1. JavaScript (+1) 2. Java (-1) 3. PHP 4. C# (+2) 5. Python (-1)

More information

Invent Your Own Computer Games with Python, 2 nd Edition. By Al Sweigart

Invent Your Own Computer Games with Python, 2 nd Edition. By Al Sweigart i Invent Your Own Computer Games with Python, 2 nd Edition By Al Sweigart ii Copyright 2008-2012 by Albert Sweigart Some Rights Reserved. "Invent Your Own Computer Games with Python" ("Invent with Python")

More information

ESCI 386 Scientific Programming, Analysis and Visualization with Python. Lesson 5 Program Control

ESCI 386 Scientific Programming, Analysis and Visualization with Python. Lesson 5 Program Control ESCI 386 Scientific Programming, Analysis and Visualization with Python Lesson 5 Program Control 1 Interactive Input Input from the terminal is handled using the raw_input() function >>> a = raw_input('enter

More information

Computers. An Introduction to Programming with Python. Programming Languages. Programs and Programming. CCHSG Visit June 2014. Dr.-Ing.

Computers. An Introduction to Programming with Python. Programming Languages. Programs and Programming. CCHSG Visit June 2014. Dr.-Ing. Computers An Introduction to Programming with Python CCHSG Visit June 2014 Dr.-Ing. Norbert Völker Many computing devices are embedded Can you think of computers/ computing devices you may have in your

More information

How to write a bash script like the python? Lloyd Huang. KaLUG - Kaohsiung Linux User Group COSCUP Aug 18 2012

How to write a bash script like the python? Lloyd Huang. KaLUG - Kaohsiung Linux User Group COSCUP Aug 18 2012 How to write a bash script like the python? Lloyd Huang KaLUG - Kaohsiung Linux User Group COSCUP Aug 18 2012 Before the start Before the start About Bash Python and me. The ipython and lpython.py. A trick,

More information

IVR Studio 3.0 Guide. May-2013. Knowlarity Product Team

IVR Studio 3.0 Guide. May-2013. Knowlarity Product Team IVR Studio 3.0 Guide May-2013 Knowlarity Product Team Contents IVR Studio... 4 Workstation... 4 Name & field of IVR... 4 Set CDR maintainence property... 4 Set IVR view... 4 Object properties view... 4

More information

Securing your Apache Tomcat installation. Tim Funk November 2009

Securing your Apache Tomcat installation. Tim Funk November 2009 Securing your Apache Tomcat installation Tim Funk November 2009 Who am I? Tomcat committer for over 7 years Day job: programmer at Armstrong World Industries. Why? function search() { var q = document.search.q.value.split(/\w+/);

More information

CSCE 110 Programming I Basics of Python: Variables, Expressions, and Input/Output

CSCE 110 Programming I Basics of Python: Variables, Expressions, and Input/Output CSCE 110 Programming Basics of Python: Variables, Expressions, and nput/output Dr. Tiffani L. Williams Department of Computer Science and Engineering Texas A&M University Fall 2011 Python Python was developed

More information

Introduction to Programming Languages and Techniques. xkcd.com FULL PYTHON TUTORIAL

Introduction to Programming Languages and Techniques. xkcd.com FULL PYTHON TUTORIAL Introduction to Programming Languages and Techniques xkcd.com FULL PYTHON TUTORIAL Last updated 9/1/2014 Full Python Tutorial Developed by Guido van Rossum in the early 1990s Named after Monty Python Available

More information

PyLmod Documentation. Release 0.1.0. MIT Office of Digital Learning

PyLmod Documentation. Release 0.1.0. MIT Office of Digital Learning PyLmod Documentation Release 0.1.0 MIT Office of Digital Learning April 16, 2015 Contents 1 Getting Started 3 2 Licensing 5 3 Table of Contents 7 3.1 PyLmod API Docs............................................

More information

latest Release 0.2.6

latest Release 0.2.6 latest Release 0.2.6 August 19, 2015 Contents 1 Installation 3 2 Configuration 5 3 Django Integration 7 4 Stand-Alone Web Client 9 5 Daemon Mode 11 6 IRC Bots 13 7 Bot Events 15 8 Channel Events 17 9

More information

Introduction to Python

Introduction to Python 1 Daniel Lucio March 2016 Creator of Python https://en.wikipedia.org/wiki/guido_van_rossum 2 Python Timeline Implementation Started v1.0 v1.6 v2.1 v2.3 v2.5 v3.0 v3.1 v3.2 v3.4 1980 1991 1997 2004 2010

More information

Intro to scientific programming (with Python) Pietro Berkes, Brandeis University

Intro to scientific programming (with Python) Pietro Berkes, Brandeis University Intro to scientific programming (with Python) Pietro Berkes, Brandeis University Next 4 lessons: Outline Scientific programming: best practices Classical learning (Hoepfield network) Probabilistic learning

More information

I don t intend to cover Python installation, please visit the Python web site for details.

I don t intend to cover Python installation, please visit the Python web site for details. Python Related Information I don t intend to cover Python installation, please visit the Python web site for details. http://www.python.org/ Before you start to use the Python Interface plugin make sure

More information

Objects and classes. Objects and classes. Jarkko Toivonen (CS Department) Programming in Python 1

Objects and classes. Objects and classes. Jarkko Toivonen (CS Department) Programming in Python 1 Objects and classes Jarkko Toivonen (CS Department) Programming in Python 1 Programming paradigms of Python Python is an object-oriented programming language like Java and C++ But unlike Java, Python doesn

More information

COMS 3101-3 Programming Languages Python: Lecture 1. Kangkook Jee [email protected]

COMS 3101-3 Programming Languages Python: Lecture 1. Kangkook Jee jikk@cs.columbia.edu COMS 3101-3 Programming Languages Python: Lecture 1 Kangkook Jee [email protected] Agenda Course descripgon IntroducGon to Python Language aspects and usage cases GeJng started How to run Python Basic

More information

Homeland Security Red Teaming

Homeland Security Red Teaming Homeland Security Red Teaming Directs intergovernmental coordination Specifies Red Teaming Viewing systems from the perspective of a potential adversary Target hardening Looking for weakness in existing

More information

Quiz I Solutions MASSACHUSETTS INSTITUTE OF TECHNOLOGY. 6.858 Fall 2012. Department of Electrical Engineering and Computer Science

Quiz I Solutions MASSACHUSETTS INSTITUTE OF TECHNOLOGY. 6.858 Fall 2012. Department of Electrical Engineering and Computer Science Department of Electrical Engineering and Computer Science MASSACHUSETTS INSTITUTE OF TECHNOLOGY 6.858 Fall 2012 Quiz I Solutions 30 Grade for q1 25 20 15 10 5 0 0 10 20 30 40 50 60 70 80 90 100 Histogram

More information

Python Basics. S.R. Doty. August 27, 2008. 1 Preliminaries 4 1.1 What is Python?... 4 1.2 Installation and documentation... 4

Python Basics. S.R. Doty. August 27, 2008. 1 Preliminaries 4 1.1 What is Python?... 4 1.2 Installation and documentation... 4 Python Basics S.R. Doty August 27, 2008 Contents 1 Preliminaries 4 1.1 What is Python?..................................... 4 1.2 Installation and documentation............................. 4 2 Getting

More information

2! Multimedia Programming with! Python and SDL

2! Multimedia Programming with! Python and SDL 2 Multimedia Programming with Python and SDL 2.1 Introduction to Python 2.2 SDL/Pygame: Multimedia/Game Frameworks for Python Literature: G. van Rossum and F. L. Drake, Jr., An Introduction to Python -

More information

Objective-C and Cocoa User Guide and Reference Manual. Version 5.0

Objective-C and Cocoa User Guide and Reference Manual. Version 5.0 Objective-C and Cocoa User Guide and Reference Manual Version 5.0 Copyright and Trademarks LispWorks Objective-C and Cocoa Interface User Guide and Reference Manual Version 5.0 March 2006 Copyright 2006

More information

Financial Accounting Tutorial

Financial Accounting Tutorial Financial Accounting Tutorial About the Tutorial Python is a general-purpose interpreted, interactive, object-oriented, and high-level programming language. It was created by Guido van Rossum during 1985-1990.

More information

Python API. About the Python API. Using Python. Cisco Python Package. About the Python API, page 1 Using Python, page 1

Python API. About the Python API. Using Python. Cisco Python Package. About the Python API, page 1 Using Python, page 1 About the, page 1 Using Python, page 1 About the Python is an easy to learn, powerful programming language. It has efficient high-level data structures and a simple but effective approach to object-oriented

More information

Monitoring Agent for PostgreSQL 1.0.0 Fix Pack 10. Reference IBM

Monitoring Agent for PostgreSQL 1.0.0 Fix Pack 10. Reference IBM Monitoring Agent for PostgreSQL 1.0.0 Fix Pack 10 Reference IBM Monitoring Agent for PostgreSQL 1.0.0 Fix Pack 10 Reference IBM Note Before using this information and the product it supports, read the

More information

Wrocław University of Technology. Bioinformatics. Borys Szefczyk. Applied Informatics. Wrocław (2010)

Wrocław University of Technology. Bioinformatics. Borys Szefczyk. Applied Informatics. Wrocław (2010) Wrocław University of Technology Bioinformatics Borys Szefczyk Applied Informatics Wrocław (2010) Copyright c : by Wrocław University of Technology Wrocław (2010) Project Office ul. M. Smoluchowskiego

More information

Computer Science 1 CSci 1100 Lecture 3 Python Functions

Computer Science 1 CSci 1100 Lecture 3 Python Functions Reading Computer Science 1 CSci 1100 Lecture 3 Python Functions Most of this is covered late Chapter 2 in Practical Programming and Chapter 3 of Think Python. Chapter 6 of Think Python goes into more detail,

More information

Python Tutorial. Release 3.2.3. Guido van Rossum Fred L. Drake, Jr., editor. June 18, 2012. Python Software Foundation Email: docs@python.

Python Tutorial. Release 3.2.3. Guido van Rossum Fred L. Drake, Jr., editor. June 18, 2012. Python Software Foundation Email: docs@python. Python Tutorial Release 3.2.3 Guido van Rossum Fred L. Drake, Jr., editor June 18, 2012 Python Software Foundation Email: [email protected] CONTENTS 1 Whetting Your Appetite 3 2 Using the Python Interpreter

More information

CS177 MIDTERM 2 PRACTICE EXAM SOLUTION. Name: Student ID:

CS177 MIDTERM 2 PRACTICE EXAM SOLUTION. Name: Student ID: CS177 MIDTERM 2 PRACTICE EXAM SOLUTION Name: Student ID: This practice exam is due the day of the midterm 2 exam. The solutions will be posted the day before the exam but we encourage you to look at the

More information

ft6 Motivation next step: perform the tests usually tedious, error prone work aided by a tool easily repeatable enter ft6 ft6

ft6 Motivation next step: perform the tests usually tedious, error prone work aided by a tool easily repeatable enter ft6 ft6 ft6 Motivation next step: perform the tests usually tedious, error prone work aided by a tool easily repeatable enter ft6 Oliver Eggert (Universität Potsdam) ft6: firewall tester for IPv6 Folie 1 von 25

More information

An introduction to Python for absolute beginners

An introduction to Python for absolute beginners An introduction to Python for absolute beginners Bob Dowling University Information Services [email protected] http://www.ucs.cam.ac.uk/docs/course-notes/unix-courses/pythonab 1 Welcome

More information

Data Mining with Python (Working draft)

Data Mining with Python (Working draft) Data Mining with Python (Working draft) Finn Årup Nielsen May 8, 2015 Contents Contents List of Figures List of Tables i vii ix 1 Introduction 1 1.1 Other introductions to Python?...................................

More information

Java Interview Questions and Answers

Java Interview Questions and Answers 1. What is the most important feature of Java? Java is a platform independent language. 2. What do you mean by platform independence? Platform independence means that we can write and compile the java

More information

Embed Python scripting in C applications

Embed Python scripting in C applications Embed Python scripting in C applications ibm.com/developerworks Table of contents If you're viewing this document online, you can click any of the topics below to link directly to that section. 1. Before

More information

Introduction to Java

Introduction to Java Introduction to Java The HelloWorld program Primitive data types Assignment and arithmetic operations User input Conditional statements Looping Arrays CSA0011 Matthew Xuereb 2008 1 Java Overview A high

More information

Informatica e Sistemi in Tempo Reale

Informatica e Sistemi in Tempo Reale Informatica e Sistemi in Tempo Reale Introduction to C programming Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa October 25, 2010 G. Lipari (Scuola Superiore Sant Anna)

More information

Outline Basic concepts of Python language

Outline Basic concepts of Python language Data structures: lists, tuples, sets, dictionaries Basic data types Examples: int: 12, 0, -2 float: 1.02, -2.4e2, 1.5e-3 complex: 3+4j bool: True, False string: "Test string" Conversion between types int(-2.8)

More information

APScheduler Documentation

APScheduler Documentation APScheduler Documentation Release 2.1.2 Alex Grönholm September 06, 2014 Contents 1 Introduction 3 2 Features 5 3 Usage 7 3.1 Installing APScheduler.......................................... 7 3.2 Starting

More information

Python Evaluation Rules

Python Evaluation Rules Python Evaluation Rules UW CSE 160 http://tinyurl.com/dataprogramming Michael Ernst and Isaac Reynolds [email protected] August 2, 2016 Contents 1 Introduction 2 1.1 The Structure of a Python Program................................

More information

Homework 2. A 4*4 image with 16 pixels Borders unaltered. Color of B2 = Average color of (B1,A2,B3,C2) A1 A2 A3 A4 B1 B2 B3 B4 C1 C2 C3 C4 D1 D2 D3 D4

Homework 2. A 4*4 image with 16 pixels Borders unaltered. Color of B2 = Average color of (B1,A2,B3,C2) A1 A2 A3 A4 B1 B2 B3 B4 C1 C2 C3 C4 D1 D2 D3 D4 Homework 2 A 4*4 image with 16 pixels Borders unaltered A1 A2 A3 A4 B1 B2 B3 B4 C1 C2 C3 C4 D1 D2 D3 D4 Color of B2 = Average color of (B1,A2,B3,C2) Swap function Example: (swap_buggy.py) >>> a = 1...

More information

TypeScript for C# developers. Making JavaScript manageable

TypeScript for C# developers. Making JavaScript manageable TypeScript for C# developers Making JavaScript manageable Agenda What is TypeScript OO in TypeScript Closure Generics Iterators Asynchronous programming Modularisation Debugging TypeScript 2 What is TypeScript

More information

Crash Dive into Python

Crash Dive into Python ECPE 170 University of the Pacific Crash Dive into Python 2 Lab Schedule Ac:vi:es Assignments Due Today Lab 11 Network Programming Due by Dec 1 st 5:00am Python Lab 12 Next Week Due by Dec 8 th 5:00am

More information

Unix Scripts and Job Scheduling

Unix Scripts and Job Scheduling Unix Scripts and Job Scheduling Michael B. Spring Department of Information Science and Telecommunications University of Pittsburgh [email protected] http://www.sis.pitt.edu/~spring Overview Shell Scripts

More information

Leak Check Version 2.1 for Linux TM

Leak Check Version 2.1 for Linux TM Leak Check Version 2.1 for Linux TM User s Guide Including Leak Analyzer For x86 Servers Document Number DLC20-L-021-1 Copyright 2003-2009 Dynamic Memory Solutions LLC www.dynamic-memory.com Notices Information

More information

The Smalltalk Programming Language. Beatrice Åkerblom [email protected]

The Smalltalk Programming Language. Beatrice Åkerblom beatrice@dsv.su.se The Smalltalk Programming Language Beatrice Åkerblom [email protected] 'The best way to predict the future is to invent it' - Alan Kay. History of Smalltalk Influenced by Lisp and Simula Object-oriented

More information

Python for Rookies. Example Examination Paper

Python for Rookies. Example Examination Paper Python for Rookies Example Examination Paper Instructions to Students: Time Allowed: 2 hours. This is Open Book Examination. All questions carry 25 marks. There are 5 questions in this exam. You should

More information

Writing robust scientific code with testing (and Python) Pietro Berkes, Enthought UK

Writing robust scientific code with testing (and Python) Pietro Berkes, Enthought UK Writing robust scientific code with testing (and Python) Pietro Berkes, Enthought UK Modern programming practices and science } Researchers and scientific software developers write software daily, but

More information

Django Two-Factor Authentication Documentation

Django Two-Factor Authentication Documentation Django Two-Factor Authentication Documentation Release 1.3.1 Bouke Haarsma April 05, 2016 Contents 1 Requirements 3 1.1 Django.................................................. 3 1.2 Python..................................................

More information

The C Programming Language course syllabus associate level

The C Programming Language course syllabus associate level TECHNOLOGIES The C Programming Language course syllabus associate level Course description The course fully covers the basics of programming in the C programming language and demonstrates fundamental programming

More information

GDB Tutorial. A Walkthrough with Examples. CMSC 212 - Spring 2009. Last modified March 22, 2009. GDB Tutorial

GDB Tutorial. A Walkthrough with Examples. CMSC 212 - Spring 2009. Last modified March 22, 2009. GDB Tutorial A Walkthrough with Examples CMSC 212 - Spring 2009 Last modified March 22, 2009 What is gdb? GNU Debugger A debugger for several languages, including C and C++ It allows you to inspect what the program

More information

Application Note 49. Using the Digi TransPort Fleet Card. October 2011

Application Note 49. Using the Digi TransPort Fleet Card. October 2011 Application Note 49 Using the Digi TransPort Fleet Card October 2011 Contents 1 INTRODUCTION... 3 1.1 Outline... 3 1.2 Assumptions... 3 1.3 Corrections... 3 1.4 Version... 3 2 Fleet card Features... 4

More information

Exercise 1: Python Language Basics

Exercise 1: Python Language Basics Exercise 1: Python Language Basics In this exercise we will cover the basic principles of the Python language. All languages have a standard set of functionality including the ability to comment code,

More information

Archelon Documentation

Archelon Documentation Archelon Documentation Release 0.6.0 Carson Gee October 05, 2015 Contents 1 Archelon Client 3 1.1 Installation................................................ 3 1.2 Web Enabled History...........................................

More information

Firewall Testing Methodology W H I T E P A P E R

Firewall Testing Methodology W H I T E P A P E R Firewall ing W H I T E P A P E R Introduction With the deployment of application-aware firewalls, UTMs, and DPI engines, the network is becoming more intelligent at the application level With this awareness

More information

COSC 6397 Big Data Analytics. 2 nd homework assignment Pig and Hive. Edgar Gabriel Spring 2015

COSC 6397 Big Data Analytics. 2 nd homework assignment Pig and Hive. Edgar Gabriel Spring 2015 COSC 6397 Big Data Analytics 2 nd homework assignment Pig and Hive Edgar Gabriel Spring 2015 2 nd Homework Rules Each student should deliver Source code (.java files) Documentation (.pdf,.doc,.tex or.txt

More information

Resco CRM Server Guide. How to integrate Resco CRM with other back-end systems using web services

Resco CRM Server Guide. How to integrate Resco CRM with other back-end systems using web services Resco CRM Server Guide How to integrate Resco CRM with other back-end systems using web services Integrating Resco CRM with other back-end systems using web services (Data, Metadata) This document consists

More information

The PHP 5.4 Features You Will Actually Use

The PHP 5.4 Features You Will Actually Use The PHP 5.4 Features You Will Actually Use About Me Lorna Jane Mitchell PHP Consultant/Developer Author of PHP Master Twitter: @lornajane Website: http://lornajane.net 2 About PHP 5.4 New features Traits

More information

Computational Mathematics with Python

Computational Mathematics with Python Computational Mathematics with Python Basics Claus Führer, Jan Erik Solem, Olivier Verdier Spring 2010 Claus Führer, Jan Erik Solem, Olivier Verdier Computational Mathematics with Python Spring 2010 1

More information

Advanced Bash Scripting. Joshua Malone ([email protected])

Advanced Bash Scripting. Joshua Malone (jmalone@ubergeeks.com) Advanced Bash Scripting Joshua Malone ([email protected]) Why script in bash? You re probably already using it Great at managing external programs Powerful scripting language Portable and version-stable

More information

Finding XSS in Real World

Finding XSS in Real World Finding XSS in Real World by Alexander Korznikov [email protected] 1 April 2015 Hi there, in this tutorial, I will try to explain how to find XSS in real world, using some interesting techniques. All

More information

Using PyObjC for Developing Cocoa Applications with Python

Using PyObjC for Developing Cocoa Applications with Python Search Advanced Search Log In Not a Member? Contact ADC ADC Home > Cocoa > While Cocoa applications are generally written in Objective-C, Python is a fully capable choice for application development. Python

More information