mirror of
https://gitee.com/openharmony/useriam_user_auth_framework
synced 2024-12-04 05:51:16 +00:00
!554 IDM Coauth模块dump接口增加fuzz
Merge pull request !554 from liuziwei/master
This commit is contained in:
commit
5420cf6ae4
@ -37,6 +37,11 @@ namespace OHOS {
|
||||
namespace UserIam {
|
||||
namespace CoAuth {
|
||||
namespace {
|
||||
const int CMD_LEN = 19;
|
||||
std::u16string cmd[] = {u"-h", u"-lc", u"-ls", u"-c", u"-c [base system]", u"-s", u"-s [SA0 SA1]", u"-s [SA] -a [-h]",
|
||||
u"-e", u"--net", u"--storage", u"-p", u"-p [pid]", u"--cpuusage [pid]", u"cified pid", u"--cpufreq", u"--mem [pid]",
|
||||
u"--zip", u"--mem-smaps pid [-v]"};
|
||||
|
||||
class CoAuthServiceFuzzer : public ExecutorCallbackInterface {
|
||||
public:
|
||||
CoAuthServiceFuzzer(int32_t onBeginExecuteResult, int32_t onEndExecuteResult, int32_t onSetPropertyResult,
|
||||
@ -152,11 +157,26 @@ void FuzzFinish(Parcel &parcel)
|
||||
IAM_LOGI("FuzzFinish end");
|
||||
}
|
||||
|
||||
void FuzzDump(Parcel &parcel)
|
||||
{
|
||||
IAM_LOGI("FuzzDump begin");
|
||||
std::vector<uint8_t> msg;
|
||||
Common::FillFuzzUint8Vector(parcel, msg);
|
||||
int32_t fd = parcel.ReadInt32();
|
||||
std::vector<std::u16string> args;
|
||||
for (uint32_t i = 0; i < msg.size(); i++) {
|
||||
args.push_back(cmd[msg[i] % CMD_LEN]);
|
||||
}
|
||||
g_coAuthService.Dump(fd, args);
|
||||
IAM_LOGI("FuzzDump end");
|
||||
}
|
||||
|
||||
using FuzzFunc = decltype(FuzzRegister);
|
||||
FuzzFunc *g_fuzzFuncs[] = {
|
||||
FuzzRegister,
|
||||
FuzzSendData,
|
||||
FuzzFinish,
|
||||
FuzzDump,
|
||||
};
|
||||
|
||||
void CoAuthFuzzTest(const uint8_t *data, size_t size)
|
||||
|
@ -161,7 +161,7 @@ void FuzzAuth(Parcel &parcel)
|
||||
if (parcel.ReadBool()) {
|
||||
callback = new (nothrow) DummyUserAuthCallback();
|
||||
}
|
||||
g_userAuthService.AuthUser(apiVersion, challenge, authType, authTrustLevel, callback);
|
||||
g_userAuthService.Auth(apiVersion, challenge, authType, authTrustLevel, callback);
|
||||
IAM_LOGI("end");
|
||||
}
|
||||
|
||||
|
@ -33,6 +33,11 @@ namespace OHOS {
|
||||
namespace UserIam {
|
||||
namespace UserAuth {
|
||||
namespace {
|
||||
const int CMD_LEN = 19;
|
||||
std::u16string cmd[] = {u"-h", u"-lc", u"-ls", u"-c", u"-c [base system]", u"-s", u"-s [SA0 SA1]", u"-s [SA] -a [-h]",
|
||||
u"-e", u"--net", u"--storage", u"-p", u"-p [pid]", u"--cpuusage [pid]", u"cified pid", u"--cpufreq", u"--mem [pid]",
|
||||
u"--zip", u"--mem-smaps pid [-v]"};
|
||||
|
||||
class DummyIdmGetCredentialInfoCallback : public IdmGetCredInfoCallbackInterface {
|
||||
public:
|
||||
void OnCredentialInfos(const std::vector<CredentialInfo> &credInfoList) override
|
||||
@ -206,6 +211,20 @@ void FuzzDelUser(Parcel &parcel)
|
||||
IAM_LOGI("end");
|
||||
}
|
||||
|
||||
void FuzzDump(Parcel &parcel)
|
||||
{
|
||||
IAM_LOGI("FuzzDump begin");
|
||||
std::vector<uint8_t> msg;
|
||||
Common::FillFuzzUint8Vector(parcel, msg);
|
||||
int32_t fd = parcel.ReadInt32();
|
||||
std::vector<std::u16string> args;
|
||||
for (uint32_t i = 0; i < msg.size(); i++) {
|
||||
args.push_back(cmd[msg[i] % CMD_LEN]);
|
||||
}
|
||||
g_UserIdmService.Dump(fd, args);
|
||||
IAM_LOGI("FuzzDump end");
|
||||
}
|
||||
|
||||
void DelCredential(Parcel &parcel)
|
||||
{
|
||||
IAM_LOGI("begin");
|
||||
@ -230,6 +249,7 @@ FuzzFunc *g_fuzzFuncs[] = {
|
||||
FuzzEnforceDelUser,
|
||||
FuzzDelUser,
|
||||
DelCredential,
|
||||
FuzzDump,
|
||||
};
|
||||
|
||||
void UserIdmFuzzTest(const uint8_t *data, size_t size)
|
||||
|
Loading…
Reference in New Issue
Block a user