473,804 Members | 3,700 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Restricted Access

I'm developing a webIDE for python and I've 2 questions regarding it.

1. How can i disable some of the modules without deleting. e.g I wish
to disable "os" module.
2. How can i force user code to access only his particular folder, I
dont want to create uses in unix, e.g

fp = open(PATH, 'w') # If this PATH is defined then use can access
files else he cant .. is there is any way?

Regards!
iapain

Jul 10 '06
21 1728
Le mercredi 12 juillet 2006 08:17, iapain a écrit*:
>
I'm having currently working on OS/2 and Linux platform, I've designed
a web based ide for python and i wish to restrict some commands
There is a restricted environment in Zope for TTW python scripts and
ZPT/DTML .

These scripts are run in the Zope process in a very restricted environment
which forbid the use of most builtins and allow the import of a limited list
of modules.

Why don't use the RestrictedPytho n module from Zope (2.8 and up) and adapt it
a bit. It seems loose coupled to the Zope internals (except for the
multimapping class which is an extension class, but I doubt it's really a
problem). It shouldn't be a too hard.

You'll need to make your own AccessControl/ZopeGuards.py-like module, and
probably subclass the RestrictionMuta tor to enable/disable certain
functionnality (interdiction of names beginning by '_' for example is hard
coded).
At last, you will get a simple example of the usage of the whole beast from
your own interpreter in Products/PythonScripts.

and
user can only access i.e rwx in his folder.
This should be possible by providing a wrapper function for file and open (see
the Guards.py module).

IMO, it worth to be tried, and I don't see any other short-term, less hacky,
solution.

regards,

--
_____________

Maric Michaud
_____________

Aristote - www.aristote.info
3 place des tapis
69004 Lyon
Tel: +33 426 880 097
Jul 12 '06 #21
You'll need to make your own AccessControl/ZopeGuards.py-like module, and
probably subclass the RestrictionMuta tor to enable/disable certain
functionnality (interdiction of names beginning by '_' for example is hard
coded).
Your reply is pretty hopeful, I saw that one, its the only fractional
part. I'm agree with others that I need to setup a safe runtime
enviornment rather than detecting harmful code.
This should be possible by providing a wrapper function for file and open (see
the Guards.py module).
Thats a nice idea, I guess it should work. I should try it really
quick! Thanks!

Best!
iapain

Jul 12 '06 #22

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

30
2583
by: Sean R. Lynch | last post by:
I've been playing around with Zope's RestrictedPython, and I think I'm on the way to making the modifications necessary to create a capabilities-based restricted execution system. The idea is to strip out any part of RestrictedPython that's not necessary for doing capabilities and do all security using just capabilities. The basic idea behind capabilities is that you don't give any piece of code you don't trust a reference to something...
13
4035
by: Rolf Magnus | last post by:
Hi, I would like to embed a python interpreter within a program, but since that program would be able to automatically download scripts from the internet, I'd like to run those in a restricted environment, which basically means that I want to allow only a specific set of modules to be used by the scripts, so that it wouldn't be possible for them to remove files from the hard drive, kill processes or do other nasty stuff. Is there any...
1
7932
by: sriram | last post by:
Hi, I am seeing a weird problem with DB2 8.2. When we connect to the database using the following command in db2 CLP db2 connect to <dbname> user <user> using <passwd> I get the following error, "userid disabled or restricted"
44
4959
by: Julian V. Noble | last post by:
Dear C Mavens, Anyone here getting hosts of spam with nefarious attachments, purporting to be from M$ or its lackeys, into your mailbox? I neglected to spoof my header, and since Hurricane Isabel I have gotten well over 10K such messages. --
5
2601
by: Peter Ammon | last post by:
It's my understanding that the printf() function is declared as int printf(const char * restrict format, ...); in stdio.h. And loosely speaking, if a parameter is declared as restricted, then accesses to the object must go through that parameter. Does this mean that printf("%s", "%s");
0
1107
by: Jussi | last post by:
Hi! I have a COM server object in which I have set certain interfaces restricted/hidden. For example With VB client these attributes works as excpected. However if I use this same COM component from C# client hidden/restricted attributes seems to have no effect. Is there any way to restrict C# client's access to certain
1
7763
by: Kiran_Juikar | last post by:
In my application, I want to copy some file from network location to local machine folder. It works fine for administrator but If I run it with restricted user (not having permissions to local machine folder) it gives me Access denied error. How can I programmatically give permission to the foder for restrcited user.
5
1620
by: Steve | last post by:
Hi All I have several vb.net 2005 apps which have run fine until now A new customer has set up windows XP with restricted users When my application starts I get errors, when accessing the registry etc, due to insufficent rights for the user If I create a keyfile and set my app to full trust in project settings, many
4
1465
by: Spiros Bousbouras | last post by:
Is there a way to mimick restricted pointers using array syntax ? So I'm looking for something to add to a statement such as "int arr" which will tell the compiler that I will only access the contents of the array through arr. If I was using pointers I would do for example int * restrict p = malloc(50 * sizeof(int)) Is there a way to do the same thing using arrays ?
0
9706
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9582
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10335
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10323
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9157
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6854
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5652
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3821
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2993
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.