!99 修复FUZZ用例告警

Merge pull request !99 from 金方鑫/master
This commit is contained in:
openharmony_ci 2024-11-21 07:36:24 +00:00 committed by Gitee
commit d9238de84a
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 25 additions and 1 deletions

View File

@ -392,7 +392,9 @@ void SecurityCollectorManagerProxyFuzzTest(const uint8_t* data, size_t size)
sptr<IRemoteObject> obj(new (std::nothrow) MockRemoteObject());
sptr<Security::SecurityCollector::SecurityCollectorManagerCallbackService> callback =
new (std::nothrow) Security::SecurityCollector::SecurityCollectorManagerCallbackService(nullptr);
SecurityCollectorSubscribeInfo subscribeInfo{};
std::string string(reinterpret_cast<const char *>(data), size);
int64_t int64 = *(reinterpret_cast<const int64_t *>(data));
SecurityCollectorSubscribeInfo subscribeInfo({int64, string, string, string});
SecurityCollectorManagerProxy proxy{obj};
std::vector<SecurityEventRuler> rulers{};
std::vector<SecurityEvent> events{};

View File

@ -171,6 +171,17 @@ void OnRemoteUnsubscribeRequest(const uint8_t* data, size_t size, MessageParcel*
SGLOGI("DataCollectManagerCallbackService called");
return 0;
};
int64_t eventId = static_cast<int64_t>(size);
std::string version(reinterpret_cast<const char *>(data), size);
std::string content(reinterpret_cast<const char *>(data), size);
std::string extra(reinterpret_cast<const char *>(data), size);
int64_t duration = static_cast<int64_t>(size);
SecurityCollector::Event event;
event.eventId = eventId;
event.version = version;
event.content = content;
event.extra = extra;
SecurityCollector::SecurityCollectorSubscribeInfo subscriberInfo{event, duration, true};
sptr<IRemoteObject> callback = new (std::nothrow) DataCollectManagerCallbackService(func);
datas->WriteRemoteObject(callback);
g_service.OnRemoteRequest(DataCollectManagerStub::CMD_DATA_UNSUBSCRIBE, *datas, *reply, *option);
@ -271,6 +282,17 @@ void OnRemoteSecurityEventConfigQuery(const uint8_t* data, size_t size, MessageP
SGLOGI("DataCollectManagerCallbackService called");
return 0;
};
int64_t eventId = static_cast<int64_t>(size);
std::string version(reinterpret_cast<const char *>(data), size);
std::string content(reinterpret_cast<const char *>(data), size);
std::string extra(reinterpret_cast<const char *>(data), size);
int64_t duration = static_cast<int64_t>(size);
SecurityCollector::Event event;
event.eventId = eventId;
event.version = version;
event.content = content;
event.extra = extra;
SecurityCollector::SecurityCollectorSubscribeInfo subscriberInfo{event, duration, true};
sptr<IRemoteObject> callback = new (std::nothrow) DataCollectManagerCallbackService(func);
datas->WriteRemoteObject(callback);
g_service.OnRemoteRequest(DataCollectManagerStub::CMD_SECURITY_EVENT_CONFIG_QUERY, *datas, *reply, *option);