mirror of
https://github.com/openharmony/ability_ability_runtime.git
synced 2026-08-24 22:21:36 -04:00
!19211 merge cli into master
revert idl Created-by: wendel Commit-by: wendel Merged-by: openharmony_ci Description: **IssueNo**: https://gitcode.com/openharmony/ability_ability_runtime/issues/15157 **Description**: **稳定性自检:** | 自检项 | 自检结果 | | ------------------------------------------------------------ | -------- | | 涉及跨进程调用的相关操作需要抛至主线程或加锁防止并发 | pass | | 成员变量进行赋值或创建需要排查并发 | pass | | 谨慎在lambda表达式中使用引用捕获 | pass | | 谨慎在未经拷贝的情况下使用外部传入的string、C字符串 | pass | | map\vector\list\set等stl模板类使用时需要排查并发 | pass | | 谨慎考虑加锁范围 | pass | | 在IPC通信中谨慎使用同步通信方式 | pass | | 禁止传递this指针至其他模块或线程(特别是eventhandler任务) | pass | | 禁止将外部传入的裸指针在内部直接构造智能指针 | pass | | 禁止多个独立创建的智能指针管理同一地址 | pass | | 禁止在析构函数中抛异步任务 | pass | | 禁止js对象在非js线程(例如在IPC线程)创建、使用或销毁 | pass | | 禁止在对外接口中未经判空直接使用外部传入的指针 | pass | | 禁止接口返回局部变量引用 | pass | | 禁止在信号函数中加锁 | pass | | 禁止在关键流程(SA启动、应用启动等主流程)执行耗时的操作 |pass | | 禁止将同一个cpp编译在不同的so中 | pass | **安全编码自检:** | 自检项 | 自检结果 | | -------------------------------------------------------------- | -------- | | 裸指针避免通过隐式转换构造为sptr | pass | | json对象在取值之前必须先判断类型,避免类型不匹配 | pass | | 序列化时必须对传入的数组大小进行校验,避免出现超大数组 | pass | | 避免使用未明确位宽的整型,选择使用int8_t、uint8_t等类型 | pass | | 外部传入的路径要做规范化校验,对路径中的.、..、../等特殊字符严格校验 | pass | | 指针变量、表示资源描述符的变量、bool变量必须赋初值 | pass | | readParcelable获取的对象使用前需要判空 | pass | | 分配和释放内存的函数需要成对出现 | pass | | 申请内存后异常退出前需要及时进行内存释放 | pass | | 内存申请前必须对内存大小进行合法性校验 | pass | | 内存分配后必须判断是否成功 | pass | | 禁止使用realloc、alloca函数 | pass | | 禁止打印文件路径、口令等敏感信息,如有需要,使用private修饰 | pass | | 禁止打印内存地址 | pass | | 整数之间运算时必须严格检查,确保不会出现溢出、反转、除0 | pass | | 禁止对有符号整数进行位操作符运算 | pass | | 禁止对指针进行逻辑或位运算 | pass | | 循环次数如果收外部数据控制,需要检验其合法性 | pass | | 禁止使用内存操作类危险函数,需要使用安全函数 | pass | | 谨慎使用不可重入函数 | pass | | 必须检查安全函数的返回值,并进行正确处理 | pass | | 禁止仅通过TokenType类型判断绕过权限校验 | pass | **TDD Result**:不涉及 **XTS Result**:不涉及 ### 是否已执行L0用例 - [x] 已验证 - [ ] 不涉及。如不涉及,请写明理由 See merge request: openharmony/ability_ability_runtime!19211
This commit is contained in:
@@ -52,11 +52,13 @@ ohos_shared_library("cli_tool_client") {
|
||||
sources = [
|
||||
"src/cli_mgr_load_callback.cpp",
|
||||
"src/cli_event_reply_manager.cpp",
|
||||
"src/cli_session_info.cpp",
|
||||
"src/cli_session_subscription_manager.cpp",
|
||||
"src/cli_tool_event.cpp",
|
||||
"src/cli_tool_mgr_client.cpp",
|
||||
"src/cli_tool_mgr_scheduler_recipient.cpp",
|
||||
"src/exec_options.cpp",
|
||||
"src/exec_result.cpp",
|
||||
"src/exec_tool_param.cpp",
|
||||
"src/sub_command_info.cpp",
|
||||
"src/tool_info.cpp",
|
||||
|
||||
@@ -27,21 +27,3 @@ struct CommandPermission
|
||||
List<String> permissions;
|
||||
int queryRet;
|
||||
};
|
||||
|
||||
struct ExecResult
|
||||
{
|
||||
int exitCode;
|
||||
String outputText;
|
||||
String errorText;
|
||||
int signalNumber;
|
||||
boolean timedOut;
|
||||
long executionTime;
|
||||
};
|
||||
|
||||
struct CliSessionInfo
|
||||
{
|
||||
String sessionId;
|
||||
String toolName;
|
||||
String status;
|
||||
ExecResult result;
|
||||
};
|
||||
|
||||
@@ -17,6 +17,7 @@ package OHOS.CliTool;
|
||||
|
||||
import ICliToolData;
|
||||
import ICliToolManagerScheduler;
|
||||
sequenceable CliSessionInfo..OHOS.CliTool.CliSessionInfo;
|
||||
sequenceable ExecToolParam..OHOS.CliTool.ExecToolParam;
|
||||
sequenceable OHOS.CliTool.ToolSummary;
|
||||
sequenceable ToolInfo..OHOS.CliTool.ToolInfo;
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
package OHOS.CliTool;
|
||||
|
||||
import ICliToolData;
|
||||
sequenceable CliSessionInfo..OHOS.CliTool.CliSessionInfo;
|
||||
sequenceable CliToolEvent..OHOS.CliTool.CliToolEvent;
|
||||
|
||||
interface ICliToolManagerScheduler {
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#include <vector>
|
||||
#include <optional>
|
||||
|
||||
#include "icli_tool_data.h"
|
||||
#include "cli_session_info.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace CliTool {
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (c) 2026 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_ABILITY_RUNTIME_CLI_SESSION_INFO_H
|
||||
#define OHOS_ABILITY_RUNTIME_CLI_SESSION_INFO_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "exec_result.h"
|
||||
#include "parcel.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace CliTool {
|
||||
/**
|
||||
* @struct CliSessionInfo
|
||||
* @brief Information about a CLI tool execution session.
|
||||
*/
|
||||
class CliSessionInfo : public Parcelable {
|
||||
public:
|
||||
std::string sessionId;
|
||||
std::string toolName;
|
||||
std::string status; // "running", "completed", "failed"
|
||||
std::shared_ptr<ExecResult> result = nullptr; // optional, only when status="completed" and status="failed"
|
||||
|
||||
CliSessionInfo() = default;
|
||||
|
||||
bool Marshalling(Parcel &parcel) const;
|
||||
static CliSessionInfo *Unmarshalling(Parcel &parcel);
|
||||
};
|
||||
} // namespace CliTool
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_ABILITY_RUNTIME_CLI_SESSION_INFO_H
|
||||
@@ -20,9 +20,9 @@
|
||||
#include <functional>
|
||||
#include <mutex>
|
||||
|
||||
#include "cli_session_info.h"
|
||||
#include "cli_tool_event.h"
|
||||
#include "exec_options.h"
|
||||
#include "icli_tool_data.h"
|
||||
#include "icli_tool_manager.h"
|
||||
#include "iremote_object.h"
|
||||
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (c) 2026 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_ABILITY_RUNTIME_EXEC_RESULT_H
|
||||
#define OHOS_ABILITY_RUNTIME_EXEC_RESULT_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "parcel.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace CliTool {
|
||||
/**
|
||||
* @brief Tool execution result
|
||||
*/
|
||||
class ExecResult : public Parcelable {
|
||||
public:
|
||||
int32_t exitCode = 1;
|
||||
std::string outputText = "";
|
||||
std::string errorText = "";
|
||||
int32_t signalNumber = 0;
|
||||
bool timedOut = false;
|
||||
int64_t executionTime = 0;
|
||||
|
||||
bool Marshalling(Parcel &parcel) const;
|
||||
static ExecResult *Unmarshalling(Parcel &parcel);
|
||||
};
|
||||
} // namespace CliTool
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_ABILITY_RUNTIME_EXEC_RESULT_H
|
||||
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright (c) 2026 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "cli_session_info.h"
|
||||
|
||||
#include "hilog_tag_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace CliTool {
|
||||
bool CliSessionInfo::Marshalling(Parcel &parcel) const
|
||||
{
|
||||
if (!parcel.WriteString(sessionId)) {
|
||||
return false;
|
||||
}
|
||||
if (!parcel.WriteString(toolName)) {
|
||||
return false;
|
||||
}
|
||||
if (!parcel.WriteString(status)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool hasResult = (result != nullptr);
|
||||
if (!parcel.WriteBool(hasResult)) {
|
||||
return false;
|
||||
}
|
||||
if (hasResult && !parcel.WriteParcelable(result.get())) {
|
||||
TAG_LOGE(AAFwkTag::CLI_TOOL, "Write result failed.");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
CliSessionInfo *CliSessionInfo::Unmarshalling(Parcel &parcel)
|
||||
{
|
||||
auto *info = new (std::nothrow) CliSessionInfo();
|
||||
if (info && !parcel.ReadString(info->sessionId)) {
|
||||
delete info;
|
||||
return nullptr;
|
||||
}
|
||||
if (!parcel.ReadString(info->toolName)) {
|
||||
delete info;
|
||||
return nullptr;
|
||||
}
|
||||
if (!parcel.ReadString(info->status)) {
|
||||
delete info;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool hasResult = false;
|
||||
if (!parcel.ReadBool(hasResult)) {
|
||||
delete info;
|
||||
return nullptr;
|
||||
}
|
||||
if (hasResult) {
|
||||
std::shared_ptr<ExecResult> execResult(parcel.ReadParcelable<ExecResult>());
|
||||
if (execResult == nullptr) {
|
||||
delete info;
|
||||
return nullptr;
|
||||
}
|
||||
info->result = execResult;
|
||||
}
|
||||
return info;
|
||||
}
|
||||
} // namespace CliTool
|
||||
} // namespace OHOS
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright (c) 2026 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "exec_result.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace CliTool {
|
||||
bool ExecResult::Marshalling(Parcel &parcel) const
|
||||
{
|
||||
if (!parcel.WriteInt32(exitCode)) {
|
||||
return false;
|
||||
}
|
||||
if (!parcel.WriteString(outputText)) {
|
||||
return false;
|
||||
}
|
||||
if (!parcel.WriteString(errorText)) {
|
||||
return false;
|
||||
}
|
||||
if (!parcel.WriteInt32(signalNumber)) {
|
||||
return false;
|
||||
}
|
||||
if (!parcel.WriteBool(timedOut)) {
|
||||
return false;
|
||||
}
|
||||
if (!parcel.WriteInt64(executionTime)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
ExecResult *ExecResult::Unmarshalling(Parcel &parcel)
|
||||
{
|
||||
auto *result = new (std::nothrow) ExecResult();
|
||||
if (result && !parcel.ReadInt32(result->exitCode)) {
|
||||
delete result;
|
||||
return nullptr;
|
||||
}
|
||||
if (!parcel.ReadString(result->outputText)) {
|
||||
delete result;
|
||||
return nullptr;
|
||||
}
|
||||
if (!parcel.ReadString(result->errorText)) {
|
||||
delete result;
|
||||
return nullptr;
|
||||
}
|
||||
if (!parcel.ReadInt32(result->signalNumber)) {
|
||||
delete result;
|
||||
return nullptr;
|
||||
}
|
||||
if (!parcel.ReadBool(result->timedOut)) {
|
||||
delete result;
|
||||
return nullptr;
|
||||
}
|
||||
if (!parcel.ReadInt64(result->executionTime)) {
|
||||
delete result;
|
||||
return nullptr;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
} // namespace CliTool
|
||||
} // namespace OHOS
|
||||
Reference in New Issue
Block a user