mirror of
https://github.com/openharmony/appexecfwk_standard.git
synced 2026-07-01 20:24:01 -04:00
!1435 hiduper打印deviceId匿名化处理
Merge pull request !1435 from dujingcheng/hidumper0523
This commit is contained in:
@@ -25,6 +25,7 @@ const int32_t MIN_ARGS_SIZE = 1;
|
||||
const int32_t MAX_ARGS_SIZE = 2;
|
||||
const int32_t FIRST_PARAM = 0;
|
||||
const int32_t SECOND_PARAM = 1;
|
||||
const int32_t NON_ANONYMIZE_LEN = 4;
|
||||
const std::string ARGS_HELP = "-h";
|
||||
const std::string ARGS_ABILITY = "-ability";
|
||||
const std::string ARGS_ABILITY_LIST = "-ability-list";
|
||||
@@ -42,6 +43,22 @@ const std::unordered_map<std::string, HidumpFlag> ARGS_MAP = {
|
||||
{ ARGS_BUNDLE_LIST, HidumpFlag::GET_BUNDLE_LIST },
|
||||
{ ARGS_DEVICEID, HidumpFlag::GET_DEVICEID },
|
||||
};
|
||||
|
||||
std::string AnonymizeDeviceId(const std::string &deviceId)
|
||||
{
|
||||
int32_t totalLen = static_cast<int32_t>(strlen(deviceId.c_str()));
|
||||
int32_t anonymizeCharNum = totalLen - NON_ANONYMIZE_LEN - NON_ANONYMIZE_LEN;
|
||||
if (anonymizeCharNum <= 0) {
|
||||
return deviceId;
|
||||
}
|
||||
|
||||
std::string newDeviceId;
|
||||
newDeviceId
|
||||
.append(deviceId.substr(0, NON_ANONYMIZE_LEN))
|
||||
.append(anonymizeCharNum, '*')
|
||||
.append(deviceId.substr(totalLen - NON_ANONYMIZE_LEN, NON_ANONYMIZE_LEN));
|
||||
return newDeviceId;
|
||||
}
|
||||
}
|
||||
|
||||
HidumpHelper::HidumpHelper(const std::weak_ptr<BundleDataMgr> &dataMgr)
|
||||
@@ -364,7 +381,7 @@ ErrCode HidumpHelper::GetAllDeviced(std::string &result)
|
||||
}
|
||||
|
||||
for (auto deviceId : deviceIds) {
|
||||
result.append(deviceId);
|
||||
result.append(AnonymizeDeviceId(deviceId));
|
||||
result.append("\n");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user