File tree Expand file tree Collapse file tree 2 files changed +49
-13
lines changed
src/actions/transformations Expand file tree Collapse file tree 2 files changed +49
-13
lines changed Original file line number Diff line number Diff line change @@ -30,24 +30,58 @@ namespace modsecurity {
30
30
namespace actions {
31
31
namespace transformations {
32
32
33
- CmdLine::CmdLine (std::string action)
34
- : Transformation(action) {
35
- this ->action_kind = 1 ;
36
- }
37
33
38
34
std::string CmdLine::evaluate (std::string value,
39
35
Transaction *transaction) {
40
- /* *
41
- * @todo Implement the transformation CmdLine
42
- */
43
- if (transaction) {
44
- #ifndef NO_LOGS
45
- transaction->debug (4 , " Transformation CmdLine is not implemented yet." );
46
- #endif
36
+ std::string ret;
37
+ int space = 0 ;
38
+
39
+ for (auto & a : value) {
40
+ switch (a) {
41
+ /* remove some characters */
42
+ case ' "' :
43
+ case ' \' ' :
44
+ case ' \\ ' :
45
+ case ' ^' :
46
+ // ret.append("i was here");
47
+ break ;
48
+
49
+ /* replace some characters to space (only one) */
50
+ case ' ' :
51
+ case ' ,' :
52
+ case ' ;' :
53
+ case ' \t ' :
54
+ case ' \r ' :
55
+ case ' \n ' :
56
+ if (space == 0 ) {
57
+ ret.append (" " );
58
+ space++;
59
+ }
60
+ break ;
61
+
62
+ /* remove space before / or ( */
63
+ case ' /' :
64
+ case ' (' :
65
+ if (space) {
66
+ ret.pop_back ();
67
+ }
68
+ space = 0 ;
69
+ ret.append (&a, 1 );
70
+ break ;
71
+
72
+ /* copy normal characters */
73
+ default :
74
+ char b = std::tolower (a);
75
+ ret.append (&b);
76
+ space = 0 ;
77
+ break ;
78
+ }
47
79
}
48
- return value;
80
+
81
+ return ret;
49
82
}
50
83
84
+
51
85
} // namespace transformations
52
86
} // namespace actions
53
87
} // namespace modsecurity
Original file line number Diff line number Diff line change @@ -30,7 +30,9 @@ namespace transformations {
30
30
31
31
class CmdLine : public Transformation {
32
32
public:
33
- explicit CmdLine (std::string action);
33
+ explicit CmdLine (std::string action)
34
+ : Transformation(action) { }
35
+
34
36
std::string evaluate (std::string exp,
35
37
Transaction *transaction) override ;
36
38
};
You can’t perform that action at this time.
0 commit comments