Files
ZDTT/zdtt/__pycache__/plugins.cpython-312.pyc

48 lines
5.0 KiB
Plaintext
Raw Normal View History

<EFBFBD>
<00>BiE<00> <00><><00>dZddlZddlZddlZddlmZmZmZmZhd<04>Z de
de
de fd<08>Z d e
d
e
dee
fd <0B>Z e fd ee
efde
d ee
de fd<0E>Zy)zP
Plugin utilities for ZDTT: AST validation, quarantine, and command validation.
<EFBFBD>N)<04>Dict<63>Callable<6C>Iterable<6C>Optional><00>cp<63>ls<6C>mv<6D>rm<72>su<73>cat<61>pip<69>ssh<73>zps<70>curl<72>sudo<64>wget<65>zdtt<74>chmod<6F>chown<77>python<6F>history<72>python3<6E> plugin_code<64> plugin_name<6D>returnc<00>6<00> tj|<00>}t |tj
<00>s td<03><00>|j D<00>]/}t |tjtjf<02>r<01>/t |tjtjf<02>r<01>Zt |tj<00>r<01>ut |tj<00>r<>t |jtjtjf<02>rLt |jtj<00>r&t |jjt <00>r<04><01> <0A><01>td|j"j$<00>d<05><03><00>y#t$r}td|<03><00><02><00>d}~wwxYw)z<>
Validate plugin AST to ensure no top-level code execution.
Only allows: imports, function definitions, class definitions, and docstrings.
Raises ValueError on violation.
zPlugin has syntax errors: Nz$Plugin must be a valid Python modulez/Plugin contains forbidden top-level statement: zo. Plugins can only contain imports, functions, classes, and docstrings. No top-level code execution is allowed.T)<13>ast<73>parse<73> SyntaxError<6F>
ValueError<EFBFBD>
isinstance<EFBFBD>Module<6C>body<64>Import<72>
ImportFrom<EFBFBD> FunctionDef<65>AsyncFunctionDef<65>ClassDef<65>Expr<70>value<75>Constant<6E>Str<74>str<74> __class__<5F>__name__)rr<00>tree<65>e<>stmts <20>/home/zane/ZDTT/zdtt/plugins.py<70>validate_plugin_astr4s6<00><00> ;<3B><12>y<EFBFBD>y<EFBFBD><1B>%<25><04> <16>d<EFBFBD>C<EFBFBD>J<EFBFBD>J<EFBFBD> '<27><18>?<3F>@<40>@<40><14> <09> <09>
<EFBFBD><04> <15>d<EFBFBD>S<EFBFBD>Z<EFBFBD>Z<EFBFBD><13><1E><1E>8<> 9<> <14> <15>d<EFBFBD>S<EFBFBD>_<EFBFBD>_<EFBFBD>c<EFBFBD>.B<>.B<>C<> D<> <14> <15>d<EFBFBD>C<EFBFBD>L<EFBFBD>L<EFBFBD> )<29> <14> <15>d<EFBFBD>C<EFBFBD>H<EFBFBD>H<EFBFBD> %<25><19>$<24>*<2A>*<2A>s<EFBFBD>|<7C>|<7C>S<EFBFBD>W<EFBFBD>W<EFBFBD>&=<3D>><3E><1D>d<EFBFBD>j<EFBFBD>j<EFBFBD>#<23>,<2C>,<2C>7<>!<21>$<24>*<2A>*<2A>"2<>"2<>C<EFBFBD>8<> <20><1D><18>=<3D>d<EFBFBD>n<EFBFBD>n<EFBFBD>>U<>>U<>=V<>W6<> 6<>
<EFBFBD>
<EFBFBD>!
<EFBFBD>, <10><>9 <17>;<3B><18>5<>a<EFBFBD>S<EFBFBD>9<>:<3A>:<3A><>;<3B>s<00>E<<00>< F<03>F<03>F<03> plugin_file<6C>quarantine_dirc<00><><00>tjj|<00>}tj|d<01><02>tjj ||<03>}d}tjj |<04>rntjj |<03>\}}tjj ||<06>d|<05>|<07><00><04>}|dz }tjj |<04>r<01>n tj||<04>|jd|<03>d<06><03>|jd|<04><00><02>|S#t$r!}|jd|<03>d |<08><00><04>Yd
}~y
d
}~wwxYw) z<>
Move a plugin file to quarantine directory and log the reason via caller.
Returns the final quarantine path or None on failure.
T)<01>exist_ok<6F><00>_zPlugin 'z ' quarantinedz
Moved to: zFailed to quarantine plugin 'z': N) <0C>os<6F>path<74>basename<6D>makedirs<72>join<69>exists<74>splitext<78>shutil<69>move<76>warning<6E> Exception<6F>error) r5r6<00>loggerr<00>quarantine_path<74>counter<65>name<6D>extr1s r3<00>move_to_quarantinerL8s<00><00>
<15>'<27>'<27>"<22>"<22>;<3B>/<2F>K<EFBFBD><06>K<EFBFBD>K<EFBFBD><0E><14>.<2E><18>g<EFBFBD>g<EFBFBD>l<EFBFBD>l<EFBFBD>><3E>;<3B>?<3F>O<EFBFBD><0F>G<EFBFBD>
<0C>'<27>'<27>.<2E>.<2E><1F>
)<29><16>G<EFBFBD>G<EFBFBD>$<24>$<24>[<5B>1<> <09><04>c<EFBFBD><1C>'<27>'<27>,<2C>,<2C>~<7E>$<24><16>q<EFBFBD><17> <09>#<23><15>7O<37>P<><0F><0F>1<EFBFBD> <0C><07> <0A>'<27>'<27>.<2E>.<2E><1F>
)<29>
<14><0E> <0B> <0B>K<EFBFBD><1F>1<><0E><0E><0E><18>+<2B><1D>m<EFBFBD><<3C>=<3D><0E><0E><0E><1A>O<EFBFBD>#4<>5<>6<><1E><1E><> <14><14><0E> <0C> <0C>4<>[<5B>M<EFBFBD><13>Q<EFBFBD>C<EFBFBD>H<>I<><13><><14>s<00>'AD(<00>( E<03>1E <03> E<03>plugin_commands<64>protected_commandsc<00><><00>|j<00>D<00>cgc] }||vs<01>|<03><02> }}|rtddj|<04><00>d<03><03><00>|j<00>D]\}}t |<06>r<01>td|<05>d<05><03><00>ycc}w)zx
Ensure plugins do not override protected commands and values are callable.
Raises ValueError on violation.
z1Plugin attempted to override protected commands: z, zC. This is a security violation and the plugin has been quarantined.zPlugin command 'z2' is not callable. All commands must be functions.T)<05>keysr r?<00>items<6D>callable)rMrrN<00>cmd<6D>
violations<EFBFBD>cmd_name<6D>cmd_funcs r3<00>validate_plugin_commandsrWQs<><00><00>"1<>!5<>!5<>!7<>U<>#<23>3<EFBFBD>BT<42>;T<>#<23>U<>J<EFBFBD>U<><11><18>?<3F><04> <09> <09>*<2A>@U<>?V<>WP<01> P<01>
<EFBFBD>
<EFBFBD>
.<2E>3<>3<>5<><0E><1A><08>(<28><17><08>!<21><1C>"<22>8<EFBFBD>*<2A>,^<5E>_<><0E> <0E><0E> <10><>Vs
<00> A6<04>A6)<0F>__doc__r;rBr<00>typingrrrr<00>PROTECTED_COMMANDSr-<00>boolr4rLrW<00><00>r3<00><module>r^s<><00><01><04>
<EFBFBD> <0A>
<EFBFBD>5<>5<><02><12> $<10>S<EFBFBD>$<10>s<EFBFBD>$<10>t<EFBFBD>$<10>N<14>C<EFBFBD><14><13><14><18>RU<52><1D><14>8);<3B><10><19>#<23>x<EFBFBD>-<2D>(<28><10><14><10>!<21><13> <0A><10>
<EFBFBD> r]