Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
f73f79b5
Kaydet (Commit)
f73f79b5
authored
Eki 24, 1996
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Done with this for 1.4.
üst
3a26dd88
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
66 additions
and
42 deletions
+66
-42
librestricted.tex
Doc/lib/librestricted.tex
+33
-21
librexec.tex
Doc/lib/librexec.tex
+0
-0
librestricted.tex
Doc/librestricted.tex
+33
-21
librexec.tex
Doc/librexec.tex
+0
-0
No files found.
Doc/lib/librestricted.tex
Dosyayı görüntüle @
f73f79b5
\chapter
{
Restricted Execution
}
\chapter
{
Restricted Execution
}
In general, executing Python programs have complete access to the
In general, Python programs have complete access to the underlying
underlying operating system through the various functions and classes
operating system throug the various functions and classes, For
contained in Python's modules. For example, a Python program can open
example, a Python program can open any file for reading and writing by
any file
\footnote
{
Provided the underlying OS gives you permission!
}
using the
\code
{
open()
}
built-in function (provided the underlying OS
for reading and writing by using the
gives you permission!). This is exactly what you want for most
\code
{
open()
}
built-in function. This is exactly what you want for
applications.
most applications.
There exists a class of applications for which this ``openness'' is
There is a class of applications for which this ``openness'' is
inappropriate. Take Grail: a web browser that accepts ``applets'',
inappropriate. Imagine a web browser that accepts ``applets'', snippets of
snippets of Python code, from anywhere on the Internet for execution
Python code, from anywhere on the Internet for execution on the local
on the local system. This can be used to improve the user interface
system. Since the originator of the code is unknown, it is obvious that it
of forms, for instance. Since the originator of the code is unknown,
cannot be trusted with the full resources of the local machine.
it is obvious that it cannot be trusted with the full resources of the
local machine.
\emph
{
Restricted execution
}
is the basic Python framework that allows
\emph
{
Restricted execution
}
is the basic framework in Python that allows
for the segregation of trusted and untrusted code. It is based on the
for the segregation of trusted and untrusted code. It is based on the
notion that trusted Python code (a
\emph
{
supervisor
}
) can create a
notion that trusted Python code (a
\emph
{
supervisor
}
) can create a
``padded cell' (or environment)
of
limited permissions, and run the
``padded cell' (or environment)
with
limited permissions, and run the
untrusted code within this cell. The untrusted code cannot break out
untrusted code within this cell. The untrusted code cannot break out
of its cell, and can only interact with sensitive system resources
of its cell, and can only interact with sensitive system resources
through interfaces defined
,
and managed by the trusted code. The term
through interfaces defined and managed by the trusted code. The term
``restricted execution'' is favored over
the term
``safe-Python''
``restricted execution'' is favored over ``safe-Python''
since true safety is hard to define, and is determined by the way the
since true safety is hard to define, and is determined by the way the
restricted environment is created. Note that the restricted
restricted environment is created. Note that the restricted
environments can be nested, with inner cells creating subcells of
environments can be nested, with inner cells creating subcells of
lesser, but never greater, priv
led
ge.
lesser, but never greater, priv
ile
ge.
An interesting aspect of Python's restricted execution model is that
An interesting aspect of Python's restricted execution model is that
the
attribut
es presented to untrusted code usually have the same names
the
interfac
es presented to untrusted code usually have the same names
as those presented to trusted code. Therefore no special interfaces
as those presented to trusted code. Therefore no special interfaces
need to be learned to write code designed to run in a restricted
need to be learned to write code designed to run in a restricted
environment. And because the exact nature of the padded cell is
environment. And because the exact nature of the padded cell is
...
@@ -42,11 +43,22 @@ may redefine the built-in
...
@@ -42,11 +43,22 @@ may redefine the built-in
\code
{
chroot()
}
-like operation on the
\var
{
filename
}
parameter, such
\code
{
chroot()
}
-like operation on the
\var
{
filename
}
parameter, such
that root is always relative to some safe ``sandbox'' area of the
that root is always relative to some safe ``sandbox'' area of the
filesystem. In this case, the untrusted code would still see an
filesystem. In this case, the untrusted code would still see an
\code
{
open()
}
function in its
\code
{__
builtin
__}
module
, with the same
built-in
\code
{
open()
}
function in its environment
, with the same
calling interface. The semantics would be identical too, with
calling interface. The semantics would be identical too, with
\code
{
IOError
}
s being raised when the supervisor determined that an
\code
{
IOError
}
s being raised when the supervisor determined that an
unallowable parameter is being used.
unallowable parameter is being used.
The Python run-time determines whether a particular code block is
executing in restricted execution mode based on the identity of the
\code
{__
builtins
__}
object in its global variables: if this is (the
dictionary of) the standard
\code
{__
builtin
__}
module, the code is
deemed to be unrestricted, else it is deemed to be restricted.
Python code executing in restricted mode faces a number of limitations
that are designed to prevent it from escaping from the padded cell.
For instance, the function object attribute
\code
{
func
_
globals
}
and the
class and instance object attribute
\code
{__
dict
__}
are unavailable.
Two modules provide the framework for setting up restricted execution
Two modules provide the framework for setting up restricted execution
environments:
environments:
...
...
Doc/lib/librexec.tex
Dosyayı görüntüle @
f73f79b5
This diff is collapsed.
Click to expand it.
Doc/librestricted.tex
Dosyayı görüntüle @
f73f79b5
\chapter
{
Restricted Execution
}
\chapter
{
Restricted Execution
}
In general, executing Python programs have complete access to the
In general, Python programs have complete access to the underlying
underlying operating system through the various functions and classes
operating system throug the various functions and classes, For
contained in Python's modules. For example, a Python program can open
example, a Python program can open any file for reading and writing by
any file
\footnote
{
Provided the underlying OS gives you permission!
}
using the
\code
{
open()
}
built-in function (provided the underlying OS
for reading and writing by using the
gives you permission!). This is exactly what you want for most
\code
{
open()
}
built-in function. This is exactly what you want for
applications.
most applications.
There exists a class of applications for which this ``openness'' is
There is a class of applications for which this ``openness'' is
inappropriate. Take Grail: a web browser that accepts ``applets'',
inappropriate. Imagine a web browser that accepts ``applets'', snippets of
snippets of Python code, from anywhere on the Internet for execution
Python code, from anywhere on the Internet for execution on the local
on the local system. This can be used to improve the user interface
system. Since the originator of the code is unknown, it is obvious that it
of forms, for instance. Since the originator of the code is unknown,
cannot be trusted with the full resources of the local machine.
it is obvious that it cannot be trusted with the full resources of the
local machine.
\emph
{
Restricted execution
}
is the basic Python framework that allows
\emph
{
Restricted execution
}
is the basic framework in Python that allows
for the segregation of trusted and untrusted code. It is based on the
for the segregation of trusted and untrusted code. It is based on the
notion that trusted Python code (a
\emph
{
supervisor
}
) can create a
notion that trusted Python code (a
\emph
{
supervisor
}
) can create a
``padded cell' (or environment)
of
limited permissions, and run the
``padded cell' (or environment)
with
limited permissions, and run the
untrusted code within this cell. The untrusted code cannot break out
untrusted code within this cell. The untrusted code cannot break out
of its cell, and can only interact with sensitive system resources
of its cell, and can only interact with sensitive system resources
through interfaces defined
,
and managed by the trusted code. The term
through interfaces defined and managed by the trusted code. The term
``restricted execution'' is favored over
the term
``safe-Python''
``restricted execution'' is favored over ``safe-Python''
since true safety is hard to define, and is determined by the way the
since true safety is hard to define, and is determined by the way the
restricted environment is created. Note that the restricted
restricted environment is created. Note that the restricted
environments can be nested, with inner cells creating subcells of
environments can be nested, with inner cells creating subcells of
lesser, but never greater, priv
led
ge.
lesser, but never greater, priv
ile
ge.
An interesting aspect of Python's restricted execution model is that
An interesting aspect of Python's restricted execution model is that
the
attribut
es presented to untrusted code usually have the same names
the
interfac
es presented to untrusted code usually have the same names
as those presented to trusted code. Therefore no special interfaces
as those presented to trusted code. Therefore no special interfaces
need to be learned to write code designed to run in a restricted
need to be learned to write code designed to run in a restricted
environment. And because the exact nature of the padded cell is
environment. And because the exact nature of the padded cell is
...
@@ -42,11 +43,22 @@ may redefine the built-in
...
@@ -42,11 +43,22 @@ may redefine the built-in
\code
{
chroot()
}
-like operation on the
\var
{
filename
}
parameter, such
\code
{
chroot()
}
-like operation on the
\var
{
filename
}
parameter, such
that root is always relative to some safe ``sandbox'' area of the
that root is always relative to some safe ``sandbox'' area of the
filesystem. In this case, the untrusted code would still see an
filesystem. In this case, the untrusted code would still see an
\code
{
open()
}
function in its
\code
{__
builtin
__}
module
, with the same
built-in
\code
{
open()
}
function in its environment
, with the same
calling interface. The semantics would be identical too, with
calling interface. The semantics would be identical too, with
\code
{
IOError
}
s being raised when the supervisor determined that an
\code
{
IOError
}
s being raised when the supervisor determined that an
unallowable parameter is being used.
unallowable parameter is being used.
The Python run-time determines whether a particular code block is
executing in restricted execution mode based on the identity of the
\code
{__
builtins
__}
object in its global variables: if this is (the
dictionary of) the standard
\code
{__
builtin
__}
module, the code is
deemed to be unrestricted, else it is deemed to be restricted.
Python code executing in restricted mode faces a number of limitations
that are designed to prevent it from escaping from the padded cell.
For instance, the function object attribute
\code
{
func
_
globals
}
and the
class and instance object attribute
\code
{__
dict
__}
are unavailable.
Two modules provide the framework for setting up restricted execution
Two modules provide the framework for setting up restricted execution
environments:
environments:
...
...
Doc/librexec.tex
Dosyayı görüntüle @
f73f79b5
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment