Edgewall Software

Ticket #394 (new enhancement)

Opened 4 years ago

Last modified 5 months ago

Allow custom loaders to also plug in custom AstTransformers

Reported by: Carsten Klein <carsten.klein@…> Owned by: cmlenz
Priority: major Milestone: 0.7
Component: General Version: 0.6
Keywords: Cc:

Description

The current API does not allow templates to override the default AstTransformer?? defined in astutil#_compile.

However, classes derived from Code do allow overriding the default transformer.

It would be nice to have a custom loader also incorporate a custom AstTransformer??.

The main concern here is security, effectfully limiting python API access by a custom AstTransformer??.

As I see it, the markup template's init method would require an additional named parameter that by default would be set to none, e.g. xform=None.

That way, upon instantiation of either Suite or Expression, the specified AstTransformer?? could be passed as an alternative the the default transformer.

This would also be backwards compatible, so existing applications would not break.

See the attached patch which might provide such a solution.

The patch is currently untested.

Attachments

external_ast_transformers.patch Download (21.0 KB) - added by Carsten Klein <carsten.klein@…> 4 years ago.

Change History

Changed 4 years ago by Carsten Klein <carsten.klein@…>

Changed 5 months ago by hodgestar

Note: It would be really hard to provide any meaningful security by examining the AST. Smart people have repeatedly failed to create Python sandboxes this way.

Add/Change #394 (Allow custom loaders to also plug in custom AstTransformers)

Author


E-mail address and user name can be saved in the Preferences.


Change Properties
<Author field>
Action
as new
as The resolution will be set. Next status will be 'closed'
to The owner will change from cmlenz. Next status will be 'new'
The owner will change from cmlenz to anonymous. Next status will be 'assigned'
 
Note: See TracTickets for help on using tickets.