Feature Extend KoLmafia with other scripting languages

lostcalpolydude

Developer
Staff member
Gausie had a twitch stream earlier today talking about https://github.com/gausie/frattlesnake. Instead of putting python in KoLmafia, it (roughly speaking) puts KoLmafia in python?

The barrier to entry seems to eliminate most of the concerns here, maybe. Until someone gets upset that their non-KoLmafia script broke because of a change to KoLmafia internals.
 

gausie

D̰͕̝͚̤̥̙̐̇̑͗̒e͍͔͎͈͔ͥ̉̔̅́̈l̠̪̜͓̲ͧ̍̈́͛v̻̾ͤe͗̃ͥ̐̊ͬp̔͒ͪ
Staff member
There are lots of points for someone who keeps a good sleep schedule in GMT+1

Jython

I thought that the PR I was doing would let me test some things and allow curious others to do the same before any formal implementation had been proposed. I have very much realised that this was a bad idea with regards to it allowing access to Java classes other than RuntimeLibrary or similar. I conceded immediately and reverted the commit and continue to be sorry.

I think the concerns aren't too complicated to address:

  • You can provide your own classloader to ScriptEngine which would restrict a script's access to Java classes. This could be used to limit the scripts to only a single standard library class. I think RuntimeLibrary would have to be modified because it is intrinsically tied to ASH through the first argument being the interpreter, but that is not a huge problem.
  • In terms of actually restricting the use of Python's own file reading libraries, I was looking into either running scripts within RestrictedPython (if that's even possible) or simply limiting the permissions granted to the Jython library so that it can't access anything at all and has to act entirely through the classes it has available to load through the ScriptEngine classloader.

I think those two would address the issues. I'm not 100% on the second bullet point because my Java isn't good enough so if it is going to stress people out I'm happy to just park it. Jython is limited for the foreseeable future to v2.7 of the Python spec which is also not ideal for both people who know Python and like v3.x and for people who don't know how to program and will learn an end-of-lifed language.

frattlesnake

I believe this is what Aenimus must have been referring to with "non-public" perhaps after having been excited during my stream. I think of that as quite a separate project (and one I've actually looked at multiple times over the last 12 months) because it doesn't involve committing any code to KoLmafia and has indeed been perfectly possible to do for many years. It's related in spirit but not in form, but by all means check out the project and see what I'm trying to do!

I think it is highlly unlikely any bug reports for this would make it to the attention of a mafia developer (other than me). To be honest, I think its highly unlikely that anyone even uses it other than me.
 
Last edited:
Top