Breaking: restrict unintended user constant usage#56
Breaking: restrict unintended user constant usage#56kares wants to merge 9 commits intologstash-plugins:mainfrom
Conversation
9e7f0a1 to
1310920
Compare
... by using a plain-old method definition we're effectively restricting "dynamic constant" assigns
|
+1. As a breaking change, we will need to guard against accidental inclusion in Logstash 7.x distributions. Preferably, we would also include a non-breaking release of this gem for inclusion in 7.x that used the deprecation logger to warn off users who exploit the current implementation.
|
Not sure we could do that with confidence, we could take a snapshot of Object constants before and after but can never know for sure the changes are only due to the executing script. Could try detecting
Dynamic constant assignment in a method is a parsing feature, of course only handles Assigning global variables is always allowed so in this case same 2 options: detect using regexp or use
Not sure as it will always have limitations. If we decide to take it all the way through a deprecation phase than its worth considering more "breaks", personally would at least decouple scripts from plugin instance, as its relative easy to run into some of the state there. |
also aligned what we rescue for inline and path scripts
|
changed the work here to be a major and also included another backwards compatibility "breaking fix" for #60 |
This change effectively restricts users shooting themselves in the foot with
code => ...such as :In filter version <= 3.1.5 this piece executes with warnings about
already initialized constant NPbut users often ignore these as they're not familiar with Ruby effectively leading to "unexpected" interference between events.The change to use normal
def self.methodopposed todefine_method { ... }with block, effectively prevents dynamic constant assignments as its not allowedThis is a breaking change - invalid
code => ...will break early on (failing to start LS).The trade-off for users to review such pieces and potentially avoid "weird" events is acceptable.
exceptionandbacktraceon Ruby raises that are getting tagged