Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Ready to be Merged] BackgroundProcessing #1451

Open
wants to merge 10 commits into
base: master
from

Conversation

@krixano
Copy link
Contributor

@krixano krixano commented Jun 9, 2018

Since Git Center is away from ZeroNet at the moment, I believe he wanted someone to create a pull request for this BackgroundProcessing plugin, since he says it is now finished.

I haven't tested this yet, but I assume @imachug has.

@imachug
Copy link
Contributor

@imachug imachug commented Jun 9, 2018

BackgroundProcessing is practically finished. However, I'd like you to test its security before. To do this, replace:

    def backgroundOutput(self, *args):
        raise NotImplementedError

with:

    def backgroundOutput(self, *args):
        print args

Now add 0background.py (print 1) to your site root and request BACKGROUND permission. You'll probably see [1] in ZeroNet console (args is a list).

Now try to do something (e.g. print eval("1")), restart ZeroNet to apply changes (to be fixed) and open console. You should see NameError: eval or something like that. Now try to escape the sandbox by using dir, etc. I hope you won't be able to hack the sandbox.

If you don't, I'll probably add update-without-restart feature and this PR can be merged.

@krixano krixano changed the title BackgroundProcessing [Testing] BackgroundProcessing Jun 9, 2018
@imachug
Copy link
Contributor

@imachug imachug commented Jul 7, 2018

Does anyone want to test this?

@DaniellMesquita
Copy link
Contributor

@DaniellMesquita DaniellMesquita commented Aug 14, 2018

@krixano @imachug how this plugin works?

@DaniellMesquita
Copy link
Contributor

@DaniellMesquita DaniellMesquita commented Aug 29, 2018

Reference: #1447.

@imachug
Copy link
Contributor

@imachug imachug commented Aug 31, 2018

This plugin allows sites to do some work in background, while the site is closed. For example, one could rebuild indexes (if you are using your own database, not SQLite), or, if your site uses my PeerMessage plugin, you could react to pings. If you need some example code, tell me, I'll post it.

@krixano
Copy link
Contributor Author

@krixano krixano commented Aug 31, 2018

I'm going to be testing this a little soon. Also, example code would be useful.

I'm wondering a few things:

  • Does the plugin allow modifying the filesystem in and not in the zite's directory, or does it delete those codes so you can't try and escape the zite's directory?
  • How would you call ZeroFrame commands from it?
@imachug
Copy link
Contributor

@imachug imachug commented Aug 31, 2018

Thank you for testing, @krixano! I'll post the example code and the answers to your question as updates to this comment right now.

@imachug
Copy link
Contributor

@imachug imachug commented Aug 31, 2018

You can use most of the default functions:

  • help, copyright, credits and license doing nothing
  • __package__ and __name__ equal to 0background
  • __doc__ = "", __debug__ = False
  • globals and locals functions
  • reload raising an exception
  • print, input and raw_input as a ways to interact with the plugin, not implemented yet -- i.e. they throw NotImplementedError
  • getattr, which allows getting all attributes, except: __subclasses__ returning everything except function and other classes that can be used to escape the sandbox, __globals__ and func_globals simulating globals(), __code__ and func_code raising TypeError
  • setattr, disallowing __subclasses__, __globals__ and __code__
@imachug
Copy link
Contributor

@imachug imachug commented Aug 31, 2018

Using ZeroFrame commands is supported:

import ZeroFrame
print ZeroFrame.cmd("siteInfo")

Or to receive commands, like setSiteInfo:

import ZeroFrame
def func(site_info):
    print site_info
ZeroFrame.on("setSiteInfo", func)
@imachug imachug force-pushed the imachug:background branch from 18ca280 to 76470fd Aug 31, 2018
@DaniellMesquita
Copy link
Contributor

@DaniellMesquita DaniellMesquita commented Aug 31, 2018

@krixano @imachug
Are you yet open to post The truth about ZeroNet on DevCenter?

@imachug
Copy link
Contributor

@imachug imachug commented Aug 31, 2018

I don't think so -- that site is outdated.

@imachug
Copy link
Contributor

@imachug imachug commented Aug 31, 2018

@DaniellMesquita What's your ID on ZeroNet?

@DaniellMesquita
Copy link
Contributor

@DaniellMesquita DaniellMesquita commented Aug 31, 2018

@DaniellMesquita What's your ID on ZeroNet?

@daniell (zeroid.bit)

@imachug
Copy link
Contributor

@imachug imachug commented Aug 31, 2018

Thank you!

@krixano krixano changed the title [Testing] BackgroundProcessing [Ready to be Merged] BackgroundProcessing Aug 31, 2018
@imachug
Copy link
Contributor

@imachug imachug commented Aug 31, 2018

@shortcutme @HelloZeroNet Finally, this PR is ready to be merged!

@imachug imachug force-pushed the imachug:background branch 2 times, most recently from b0970cf to 3502e59 Oct 29, 2018
@filips123
Copy link
Contributor

@filips123 filips123 commented May 19, 2019

@krixano @imachug @HelloZeroNet Are here also some issues? Can it be merged?

@imachug
Copy link
Contributor

@imachug imachug commented May 19, 2019

The only issue I can think of is a sandbox escape possibility - but I promise I've checked it several times. I'd like others to do it as well, though.

@filips123
Copy link
Contributor

@filips123 filips123 commented May 20, 2019

Does this also need Python 3 version?

@imachug
Copy link
Contributor

@imachug imachug commented May 21, 2019

py3 branch of the plugin repo contains the code for Python 3.

@imachug imachug force-pushed the imachug:background branch from 3502e59 to 24c0d2b Jun 26, 2019
@imachug imachug deleted the imachug:background branch Dec 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants
You can’t perform that action at this time.