Security csrf
Apply CSRF protection to state-changing controller actions and Autolyse services. Use when generating Mailchimp controllers or registering Autolyse services; follows .agent/rules/security-csrf.mdc.From its SKILL.md
npx -y skills add AravindS-Wick/aravindhan-skills --skill security-csrfAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
2.8 KB, 541 tokens by cl100k_base, as published. Nobody here has run it
Apply CSRF Protection to all state changing controller actions
Class and Function Conventions
Mailchimp controllers typically use the following class name and function name convention:
// Class name ends in Controller and extends a class whose name begins with MC_Controller_
class Account_UsersController extends MC_Controller_Action
{
// preRun method is optional and always runs first when an Action function is invoked
public function preRun()
{
parent::preRun();
// logic
}
// Conventionally, an action that just returns data, but may change state (GET request)
public function fooAction() {
// logic
}
// An action that changes state (POST request)
public function barPostAction() {
// logic
}
}
CSRF Protection Methods
The following method calls adds CSRF protection when invoked inside a Mailchimp Controller function:
$this->protectCSRF()
Rules for when to apply CSRF Protection
CSRF protection must be applied to any Mailchimp Controller Action method that is state changing. Determine if the action is state changing using the following rules:
- Code inside a controller action method whose name ends in PostAction is always state changing.
- Code inside a controller action method whose name does not end in PostAction is generally not state changing. However, to determine if it is state changing, analyze the logic of the method to determine if it is doing any "write" operations, for example, modifying or inserting a database value, or triggering an action, for example sending an email.
If the class contains a preRun method, and $this->protectCSRF() is already invoked inside that method, Controller Action methods do not need to invoke it again.
Similarly, if the preRun method of the class calls parent::preRun() or another method that already invokes the $this->protectCSRF() method, the Controller Action methods do not need to invoke it again.
Apply CSRF Protection to all Autolyse Services by default
When generating an Autolyse service, register it with CSRF Protection enabled by default.
The service registration call in app/lib/Autolyse/Services.php should include the ValidateCSRF middleware, as in this example:
private static function registerMyService(Server $server): void
{
$server->registerLazyInitializer(
MyServiceAutolyseInterface::class,
fn() => $server->register(
MyServiceAutolyseInterface::class,
self::withMiddleware(
new ValidateCSRF,
)
)
);
}
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.