xs/csrf.xs

filter: Statementstmt 100% 9 / 9 Branchbran 75.0% 3 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 92.3% 12 / 13 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« include/punk/punk_password.h ↑ Summary include/punk/punk_cache.h »
1 MODULE = Punk PACKAGE = Punk::CSRF
2  
3 PROTOTYPES: DISABLE
4  
5 # The two hooks the `csrf` keyword makes the compiler install (punk_csrf.h).
6 # lib/Punk/CSRF.pm is documentation.
7  
8 # before_dispatch: a reference return short-circuits the request, so a refusal
9 # answers 403 before any guard or handler runs. Returning nothing lets the
10 # request through - and, on the way, spends the token it arrived with.
11 void
12 _check(c)
13 SV *c
14 PPCODE:
15 {
16 89 SV *refused = pcf_check(aTHX_ c);
17 /* pcf_check ran Perl (the session load, $req->form, on_error), and
18 * Perl may have grown and so moved the value stack */
19 89 SP = PL_stack_base + ax - 1;
20 89 ▶ if (refused) {
Branch: 1 branch
BranchTrueFalseTotal
if (refused) { 32 57 89
21 32 ▶ EXTEND(SP, 1);
Branch: 1 branch
BranchTrueFalseTotal
EXTEND(SP, 1); 0 32 32
22 32 mPUSHs(refused);
23 32 XSRETURN(1);
24 }
25 57 XSRETURN_EMPTY;
26 }
27  
28 # after_dispatch: mirror the token into a script-readable cookie when it
29 # changed. Pushed after the session write-back, so both cookies go out on the
30 # same response.
31 SV *
32 _writeback(c, resp)
33 SV *c
34 SV *resp
35 CODE:
36 89 pcf_writeback(aTHX_ c, resp);
37 89 RETVAL = newSVsv(resp);
38 OUTPUT:
39 RETVAL
« include/punk/punk_password.h ↑ Summary include/punk/punk_cache.h »