File: libinjection.i

package info (click to toggle)
modsecurity 3.0.14-1
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 88,920 kB
  • sloc: ansic: 174,512; sh: 43,569; cpp: 26,214; python: 15,734; makefile: 3,864; yacc: 2,947; lex: 1,359; perl: 1,243; php: 42; tcl: 4
file content (62 lines) | stat: -rw-r--r-- 1,559 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/* libinjection.i SWIG interface file */
%module libinjection
%{
#include "libinjection.h"
#include "libinjection_sqli.h"

static char libinjection_lua_lookup_word(sfilter* sf, int lookup_type,
                                         const char* s, size_t len)
{
    lua_State* L = (lua_State*) sf->userdata;
    //char* luafunc = (char *)lua_tostring(L, 2);
    lua_getglobal(L, "lookup_word");
    SWIG_NewPointerObj(L, (void*)sf, SWIGTYPE_p_libinjection_sqli_state, 0);
    lua_pushnumber(L, lookup_type);
    lua_pushlstring(L, s, len);

    if (lua_pcall(L, 3, 1, 0)) {
        printf("Something bad happened");
    }

    const char* result = lua_tostring(L, -1);
    if (result == NULL) {
        return 0;
    } else {
        return result[0];
    }
}
%}
%include "typemaps.i"


// The C functions all start with 'libinjection_' as a namespace
// We don't need this since it's in the libinjection table
// i.e. libinjection.libinjection_is_sqli --> libinjection.is_sqli
 //
%rename("%(strip:[libinjection_])s") "";

%typemap(in) (ptr_lookup_fn fn, void* userdata) {
    if (lua_isnil(L, 1)) {
        arg2 = NULL;
        arg3 = NULL;
    } else {
        arg2 = libinjection_lua_lookup_word;
        arg3 = (void *) L;
    }
 }


%typemap(out) stoken_t [ANY] {
    int i;
    lua_newtable(L);
    for (i = 0; i < $1_dim0; i++) {
        lua_pushnumber(L, i+1);
        SWIG_NewPointerObj(L, (void*)(& $1[i]), SWIGTYPE_p_stoken_t,0);
        lua_settable(L, -3);
    }
    SWIG_arg += 1;
}


%include "libinjection.h"
%include "libinjection_sqli.h"