-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lua: provide base64 lib to lua - v2 #12498
base: master
Are you sure you want to change the base?
Conversation
WARNING:
Pipeline 24405 |
Information: QA ran without warnings. Pipeline 24422 |
uint8_t *decoded = SCCalloc(decoded_len, sizeof(uint8_t)); | ||
|
||
for (uint8_t mode = Base64ModeRFC2045; mode <= Base64ModeStrict; mode++) { | ||
(void)Base64Decode(src, len, mode, decoded); | ||
for (uint8_t mode = SCBase64ModeRFC2045; mode <= SCBase64ModeStrict; mode++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ouch, you changed the order in the enum, so this loop quits too early
@@ -40,7 +40,7 @@ | |||
static int DetectTransformFromSCBase64DecodeSetup(DetectEngineCtx *, Signature *, const char *); | |||
static void DetectTransformFromSCBase64DecodeFree(DetectEngineCtx *, void *); | |||
#ifdef UNITTESTS | |||
#define DETECT_TRANSFORM_FROM_BASE64_MODE_DEFAULT (uint8_t)SCBase64ModeRFC4648 | |||
#define DETECT_TRANSFORM_FROM_BASE64_MODE_DEFAULT (uint8_t) SCBase64ModeRFC4648 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not in right commit :-p
FAIL_IF_NOT(buffer.inspect_len == 15); | ||
// PrintRawDataFp(stdout, buffer.inspect, buffer.inspect_len); | ||
InspectionBufferFree(&buffer); | ||
PASS; | ||
} | ||
static void DetectTransformFromBase64DecodeRegisterTests(void) | ||
static void DetectTransformFromSCBase64DecodeRegisterTests(void) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your grep|sed is gone too far :-p
size_t input_len; | ||
const char *input = luaL_checklstring(L, 1, &input_len); | ||
size_t out_len = SCBase64EncodeBufferSize(input_len); | ||
char output[out_len + 1]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not like stack alloc... How big can it get ?
let mut num_decoded: u32 = 0; | ||
let config = base64::engine::GeneralPurposeConfig::new() | ||
.with_decode_padding_mode(base64::engine::DecodePaddingMode::Indifferent); | ||
let decoder = base64::engine::GeneralPurpose::new(&base64::alphabet::STANDARD, config); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How lenient is this ? Like tolerating spaces inside the base64 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good overall but some details to improve on like not renaming DetectTransformFromBase64DecodeRegister
to DetectTransformFromSCBase64DecodeRegister
Adds a Lua library exposing basic base64 functions to Lua. For details on the
function checkout the base64.rst page added in the userguide.
Commits:
SV_BRANCH=OISF/suricata-verify#2260