Is it possible to sniff a custom wpdb extension? #2482
-
Hi folks, Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
@nosilver4u This is currently not possible and I'm not sure it would be a good idea to allow for this. The sniffs which look for the If any variable would be allowed (even if specifically "allow listed" from a ruleset), all presumptions the sniff makes based on the use of an WPDB object become invalid.
You see what I'm getting at ? |
Beta Was this translation helpful? Give feedback.
-
Except WPCS cannot verify that.
Well, to me, it's less about the work involved in adding the feature (though a use-case of one project does not justify it), but more about potential knock-on effects and support overhead. Think of it like this: a lot of companies have their own external standards and other projects may use those standards, like the WooCommerce standard, without understanding that such a standard can change the behaviour of WPCS. Now, one of those companies adds a different variable to the allow list. Someone uses that external standard, but already uses that same variable name for something else, WPCS reports false positives/gives weird errors and the user reports a "bug" to WPCS. Another example: one of those companies adds a different variable to the allow list, but the methods in their custom class are not actually secure. Someone uses that external standard, WPCS doesn't flag any issues, but the plugin is vulnerable and gets hacked... See my problem ? |
Beta Was this translation helpful? Give feedback.
-
Thanks for the clarification, I was trying to wrap my head around how that would cause issue, and that makes more sense. I can totally see some folks saying, "Hey, we used WPCS, our code should be secure, it's not our fault!" It is, but yes, some people are not exactly reasonable. |
Beta Was this translation helpful? Give feedback.
@nosilver4u This is currently not possible and I'm not sure it would be a good idea to allow for this. The sniffs which look for the
$wpdb
variable are mostly security related sniffs.If any variable would be allowed (even if specifically "allow listed" from a ruleset), all presumptions the sniff makes based on the use of an WPDB object become invalid.
wpdb
?You see what I'm getting at ?