-
Notifications
You must be signed in to change notification settings - Fork 79
[ENHANCEMENT] Ability to blacklist specific fields #216
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
base: experimental
Are you sure you want to change the base?
[ENHANCEMENT] Ability to blacklist specific fields #216
Conversation
There's a reason I didn't add this earlier. You just added a bunch of checks to EVERY instance field query, which is done DOZENS of times on the average script. We will have to get good data on the potential performance impacts of this change especially on scripts that run in onUpdate. |
I have modified the check to only use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, I'm still a little worried about the performance impact but I don't think it'll be that big in the greater scheme of things. Maybe we can find and implement a fast map algorithm (or switch to checking for values in a flat array like ['FlxSave.resolveFlixelClasses', 'FlxSave.data']
)
I did have one note for an obvious perf improvement.
2335e49
to
9aed087
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't the same be done to these too?
for (cls => flds in PolymodScriptClass.blacklistedInstanceFields) | ||
{ | ||
if (oCls == Std.string(cls) && flds.contains(f)) | ||
{ | ||
errorEx(EInvalidAccess(f)); | ||
return null; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here
for (cls => flds in PolymodScriptClass.blacklistedInstanceFields) | ||
{ | ||
if (oCls == Std.string(cls) && flds.contains(f)) | ||
{ | ||
errorEx(EInvalidAccess(f)); | ||
return null; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and here
I don't think so because I'm changing the keys from Dynamic (Classes) to String so that they could compare with |
Git says there's still merge conflicts but it doesn't say what they are? |
bca8f1b
to
100508c
Compare
The field keys should probably be Strings to begin with for the purposes of optimization, but we can change that later. |
Just pushed a commit which improves the error handling (calling However, I'm currently experiencing an issue where |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either you or I should figure out how to properly resolve oCls for error reporting before merging.
As a reminder, the only issue with this PR is that the error message reads |
Would close issues such as FunkinCrew/Funkin#4995
Description
This PR adds two new functions to Polymod,
blacklistStaticFields
andblacklistInstanceFields
. These functions allow for specific variables and functions of the parent class to be blacklisted from usage in scripts. Blacklisted fields cannot be gotten (and thus called) or set.This PR would also remove the need to fully blacklist classes if they have a few potentially malicious fields.
Examples
Static Field Blacklisting
If in your project you were to use:
The function
resolveFlixelClasses
would be blacklisted from being used in scripts to access malicious packages.Instance Field Blacklisting
If in your project you were to use:
The field
data
would be blacklisted from bein used. This means that usingFlxG.save.data
ornew FlxSave().data
would result in an error.