namespace DPL {
namespace {
-const std::string FRAME_PATTERN_DPL("in DPL::Test");
+const char *FRAME_PATTERN = "in DPL::Test|in std::|in main";
const std::string FRAME_GDBBACKTRACE("in DPL::gdbbacktrace");
const std::string DEV_NULL("/dev/null");
const std::string TMP_FILE_PREFIX("/tmp/security-tests_gdbbacktrace-");
bool backtraceParseLine(const std::string &line, std::ostream &result, size_t lineNumber)
{
- if (line.find(FRAME_PATTERN_DPL, 0) != std::string::npos)
+ std::smatch m;
+ std::regex frame_expr(FRAME_PATTERN);
+ if (std::regex_search(line, m, frame_expr))
return false;
- std::smatch m;
std::regex expr("^#\\d+\\s+0x[0-9a-fA-F]+\\s+(.+)");
- if (!std::regex_search (line, m, expr))
+ if (!std::regex_search(line, m, expr))
return false;
result << "#" << std::left << std::setw(2) << lineNumber << " " << m[m.size()-1] << std::endl;
#define DOWNLOADED_ENC_FILE "/tmp/downloaded_enc_file"
#define PRELOADED_ENC_FILE "/tmp/preloaded_enc_file"
+namespace {
+
+const uid_t DEFAULT_UID = 5001;
+
int _read_from_file(const char* path, unsigned char** data, size_t* len)
{
int ret = WAE_ERROR_NONE;
return ret;
}
+} // namespace anonymous
+
RUNNER_TEST_GROUP_INIT(libwebappenc)
RUNNER_TEST(T01_init) {
- wae_remove_app_dek(TEST_PKGID_1, WAE_DOWNLOADED_GLOBAL_APP);
- wae_remove_app_dek(TEST_PKGID_2, WAE_PRELOADED_APP);
+ wae_remove_app_dek(DEFAULT_UID, TEST_PKGID_1);
+ wae_remove_global_app_dek(TEST_PKGID_2, true);
}
RUNNER_CHILD_TEST(T02_downloaded_web_app_enc){
unsigned char* encrypted = NULL;
size_t encLen = 0;
- wae_app_type_e appType = WAE_DOWNLOADED_GLOBAL_APP;
-
- ret = wae_encrypt_web_application(pkgId, appType,
+ ret = wae_encrypt_web_application(DEFAULT_UID, pkgId,
(const unsigned char*)plaintext, plaintextLen,
&encrypted, &encLen);
RUNNER_ASSERT_MSG(ret == WAE_ERROR_NONE, "FAIL: wae_encrypt_web_application. ret=" << ret);
unsigned char* decrypted = NULL;
size_t decLen = 0;
- wae_app_type_e appType = WAE_DOWNLOADED_GLOBAL_APP;
-
ret = _read_from_file(DOWNLOADED_ENC_FILE, &encrypted, &encLen);
RUNNER_ASSERT_MSG(ret == WAE_ERROR_NONE, "FAIL: _read_from_file. ret=" << ret);
- ret = wae_decrypt_web_application(pkgId, appType, encrypted, encLen, &decrypted, &decLen);
+ ret = wae_decrypt_web_application(DEFAULT_UID, pkgId, encrypted, encLen, &decrypted, &decLen);
RUNNER_ASSERT_MSG(ret == WAE_ERROR_NONE, "FAIL: wae_decrypt_web_application. ret=" << ret);
RUNNER_ASSERT_MSG(plaintextLen == decLen,
unsigned char* encrypted = NULL;
size_t encLen = 0;
- wae_app_type_e appType = WAE_PRELOADED_APP;
-
- ret = wae_encrypt_web_application(pkgId, appType,
+ ret = wae_encrypt_global_web_application(pkgId, true,
(const unsigned char*)plaintext, plaintextLen,
&encrypted, &encLen);
- RUNNER_ASSERT_MSG(ret == WAE_ERROR_NONE, "FAIL: wae_encrypt_web_application. ret=" << ret);
+ RUNNER_ASSERT_MSG(ret == WAE_ERROR_NONE, "FAIL: wae_encrypt_global_web_application. ret=" << ret);
ret = _write_to_file(PRELOADED_ENC_FILE, encrypted, encLen);
RUNNER_ASSERT_MSG(ret == WAE_ERROR_NONE, "FAIL: _write_to_file. file=" << DOWNLOADED_ENC_FILE);
unsigned char* decrypted = NULL;
size_t decLen = 0;
- wae_app_type_e appType = WAE_PRELOADED_APP;
-
ret = _read_from_file(PRELOADED_ENC_FILE, &encrypted, &encLen);
RUNNER_ASSERT_MSG(ret == WAE_ERROR_NONE, "FAIL: _read_from_file. ret=" << ret);
- ret = wae_decrypt_web_application(pkgId, appType, encrypted, encLen, &decrypted, &decLen);
- RUNNER_ASSERT_MSG(ret == WAE_ERROR_NONE, "FAIL: wae_decrypt_web_application. ret=" << ret);
+ ret = wae_decrypt_global_web_application(pkgId, true, encrypted, encLen, &decrypted, &decLen);
+ RUNNER_ASSERT_MSG(ret == WAE_ERROR_NONE, "FAIL: wae_decrypt_global_web_application. ret=" << ret);
RUNNER_ASSERT_MSG(plaintextLen == decLen,
"FAIL: plaintext_len("<<plaintextLen<<") != decrypted_len(" <<decLen<<")");
RUNNER_CHILD_TEST(T07_remove_app_dek) {
int ret = WAE_ERROR_NONE;
- ret = wae_remove_app_dek(TEST_PKGID_1, WAE_DOWNLOADED_GLOBAL_APP);
+ ret = wae_remove_app_dek(DEFAULT_UID, TEST_PKGID_1);
RUNNER_ASSERT_MSG(ret == WAE_ERROR_NONE, "FAIL: wae_remove_app_dek. ret=" << ret);
- ret = wae_remove_app_dek(TEST_PKGID_2, WAE_PRELOADED_APP);
- RUNNER_ASSERT_MSG(ret == WAE_ERROR_NONE, "FAIL: wae_remove_app_dek. ret=" << ret);
+ ret = wae_remove_global_app_dek(TEST_PKGID_2, true);
+ RUNNER_ASSERT_MSG(ret == WAE_ERROR_NONE, "FAIL: wae_remove_global_app_dek. ret=" << ret);
}