Skip to content

Commit

Permalink
Merge branch 'Tencent:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
bensonhome authored Jul 16, 2024
2 parents 0a549d1 + 1a450f8 commit f32bef1
Show file tree
Hide file tree
Showing 29 changed files with 954 additions and 17 deletions.
374 changes: 374 additions & 0 deletions ScriptsAPI.py

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion doc/en/quickStarted/enhanceDeploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ If you are using TCA in an enterprise intranet environment and want to experienc
:::

```shell
# install Git LFS
$ bash ./scripts/base/install_git_lfs.sh
# If the cls binary is not found in this directory, you can execute the following command to synchronize.
$ bash ./scripts/base/install_bin.sh
$ cd server/cls
Expand Down Expand Up @@ -99,7 +101,7 @@ Different deployment methods can modify the `config.ini` configuration according
- Application scenario
- (4) Then wait for the application license to be reviewed and approved, you can copy the private cloud license and continue with the following step 4.

4. After receiving the reply email from the TCA team, fill in the License in the `config.yaml` file in the CLS directory
4. Fill in the License in the `config.yaml` file in the CLS directory

::: warning
Note: Follow the yaml format, for example:
Expand Down
Binary file added doc/images/gitlab_application_01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/images/gitlab_application_02.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/images/gitlab_application_03.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/images/gitlab_application_04.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/images/gitlab_oauth_QA_01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/images/gitlab_oauth_QA_02.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/images/gitlab_oauth_QA_03.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/images/gitlab_oauth_QA_04.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/images/gitlab_oauth_QA_05.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/images/gitlab_oauth_QA_06.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/images/gitlab_oauth_QA_07.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/images/gitlab_oauth_disposition_01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/images/gitlab_oauth_disposition_02.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/images/gitlab_oauth_disposition_03.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/images/gitlab_oauth_disposition_04.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/images/gitlab_oauth_disposition_05.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/images/gitlab_oauth_disposition_06.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/images/gitlab_oauth_disposition_07.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 8 additions & 8 deletions doc/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -706,11 +706,11 @@ bl@^5.0.0:
readable-stream "^3.4.0"

braces@^3.0.2, braces@~3.0.2:
version "3.0.2"
resolved "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107"
integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==
version "3.0.3"
resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.3.tgz#490332f40919452272d55a8480adc0c441358789"
integrity sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==
dependencies:
fill-range "^7.0.1"
fill-range "^7.1.1"

browserslist@^4.21.5:
version "4.21.9"
Expand Down Expand Up @@ -915,10 +915,10 @@ fastq@^1.6.0:
dependencies:
reusify "^1.0.4"

fill-range@^7.0.1:
version "7.0.1"
resolved "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40"
integrity sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==
fill-range@^7.1.1:
version "7.1.1"
resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.1.1.tgz#44265d3cac07e3ea7dc247516380643754a05292"
integrity sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==
dependencies:
to-regex-range "^5.0.1"

Expand Down
324 changes: 324 additions & 0 deletions doc/zh/guide/服务端/ScriptAPI_guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,324 @@
# API调用脚本使用指引

## 操作步骤
#### 1. 修改脚本api_invoke.py的内部参数,填写个人令牌mytoken
#### 2. 部署代码分析服务
#### 3. 进入项目根目录
#### 4. 检查requests 模块是否安装,如未安装,可执行下列安装指令。
```bash
pip install requests
```
#### 5. 设置参数method,选择要执行的api接口,并根据接口添加所需参数。
#### 6. 执行脚本python ScriptsAPI.py

## 方法总览

| method | 类型 |
|------------------------|---------------------|
| create_repository | 创建代码库 |
| update_scheme_settings | 设置指定代码库的指定方案的代码度量配置 |
| create_project | 创建分析项目 |
| create_scans | 启动任务 |
| get_scan_cons | 轮询任务结果 |
| get_overview | 获取分析概览 |
| get_issues | 查看扫描问题列表 |
| get_issue_detail | 查看问题详情 |
| get_ccissues | 查看指定项目的圈复杂度问题列表 |
| get_dupfiles | 查看指定项目的重复文件列表 |


## API详细信息


### 一、创建代码库
#### 1. url请求
```
POST /server/main/api/orgs/<org_sid>/teams/<team_name>/repos/
```
#### 2. 参数说明
##### 脚本参数

| 字段 | 类型 | 描述 |
|-----------|-----|--------------------------|
| method | str | 调用的方法名,create_repository |
| base_url | str | 基础路径 |
| org_sid | str | 项目组名称 |
| team_name | str | 团队唯一标识 |
| scm_url | str | 代码库地址 |
| scm_type | str | 填git或svn |

##### 脚本内部参数
| Key | 类型 | Value |
|---------------|-----|----------------------|
| Authorization | str | "Token 当前user的token" |

#### 3. 操作示例
```bash
python ScriptsAPI.py --base_url=${TCA_BASE_URL} --method=create_repository --org_sid=${TCA_ORG_SID} --team_name=${TCA_TEAM_NAME} --scm_url=${TCA_SCM_URL} --scm_type=${TCA_SCM_TYPE}
```


### 二、设置指定代码库的指定方案的代码度量配置
#### 1. url请求
```
PUT /server/main/api/orgs/<org_sid>/teams/<team_name>/repos/<repo_id>/schemes/<scheme_id>/metricconf/
```
#### 2. 参数说明
##### 脚本参数

| 字段 | 类型 | 描述 |
|-----------|-----|--------------------------|
| method | str | 调用的方法名,update_scheme_settings |
| base_url | str | 基础路径 |
| org_sid | str | 项目组名称 |
| team_name | str | 团队唯一标识 |
| repo_id | str | 代码库id |
| scheme_id | str | 扫描方案id |

##### 脚本内部参数
| Key | 类型 | Value |
|---------------|-----|----------------------|
| Authorization | str | "Token 当前user的token" |

#### 3. 操作示例
```bash
python ScriptsAPI.py --base_url=${TCA_BASE_URL} --method=update_scheme_settings --org_sid=${TCA_ORG_SID} --team_name=${TCA_TEAM_NAME} --repo_id=${TCA_REPO_ID} --scheme_id=${TCA_SCHEME_ID}
```



### 三、创建分析项目
#### 1. url请求
```
POST /server/main/api/orgs/<org_sid>/teams/<team_name>/repos/<repo_id>/projects/
```
#### 2. 参数说明
##### 脚本参数

| 字段 | 类型 | 描述 |
|------------------|-----|---------------------------------------|
| method | str | 调用的方法名,create_repository |
| base_url | str | 基础路径 |
| org_sid | str | 项目组名称 |
| team_name | str | 团队唯一标识 |
| repo_id | str | 代码库id |
| scan_scheme_id | int | 和global_scheme_id二选一进行填写,当前代码库的扫描方案编号 |
| global_scheme_id | int | 和scan_scheme_id二选一进行填写,扫描方案模板编号 |
| branch | str | 分支 |


##### 脚本内部参数
| Key | 类型 | Value |
|---------------|-----|----------------------|
| Authorization | str | "Token 当前user的token" |

#### 3. 操作示例
```bash
python ScriptsAPI.py --base_url=${TCA_BASE_URL} --method=create_project --org_sid=${TCA_ORG_SID} --team_name=${TCA_TEAM_NAME} --repo_id=${TCA_REPO_ID} --scan_scheme_id=${TCA_SCAN_SCHEME_ID} --branch=${TCA_BRANCH}
```


### 四、启动任务
#### 1. url请求
```
POST /server/main/api/orgs/<org_sid>/teams/<team_name>/repos/<repo_id>/projects/<project_id>/scans/create/
```
#### 2. 参数说明
##### 脚本参数

| 字段 | 类型 | 描述 |
|------------|-----|--------------------------|
| method | str | 调用的方法名,create_scans |
| base_url | str | 基础路径 |
| org_sid | str | 项目组名称 |
| team_name | str | 团队唯一标识 |
| repo_id | str | 代码库id |
| project_id | str | 分析项目id |


##### 脚本内部参数
| Key | 类型 | Value |
|---------------|-----|----------------------|
| Authorization | str | "Token 当前user的token" |

#### 3. 操作示例
```bash
python ScriptsAPI.py --base_url=${TCA_BASE_URL} --method=create_scans --org_sid=${TCA_ORG_SID} --team_name=${TCA_TEAM_NAME} --repo_id=${TCA_REPO_ID} --project_id=${TCA_PROJECT_ID}
```



### 五、轮询任务结果
#### 1. url请求
```
GET /server/main/api/orgs/<org_sid>/teams/<team_name>/repos/<repo_id>/projects/<project_id>/jobs/<job_id>/detail/
```
#### 2. 参数说明
##### 脚本参数

| 字段 | 类型 | 描述 |
|------------|-----|--------------------------|
| method | str | 调用的方法名,get_scan_cons |
| base_url | str | 基础路径 |
| org_sid | str | 项目组名称 |
| team_name | str | 团队唯一标识 |
| repo_id | str | 代码库id |
| project_id | str | 分析项目id |

##### 脚本内部参数
| Key | 类型 | Value |
|--|------| - |
| Authorization | str | "Token 当前user的token" |
| sleeptime | int | 轮询间隔的时间 |

#### 3. 操作示例
```bash
python ScriptsAPI.py --base_url=${TCA_BASE_URL} --method=get_scan_cons --org_sid=${TCA_ORG_SID} --team_name=${TCA_TEAM_NAME} --repo_id=${TCA_REPO_ID} --project_id=${TCA_PROJECT_ID} --job_id=${TCA_JOB_ID}
```


### 六、获取分析概览
#### 1. url请求
```
GET /server/analysis/api/orgs/<org_sid>/teams/<team_name>/repos/<repo_id>/projects/<project_id>/overview/
```
#### 2. 参数说明
##### 脚本参数

| 字段 | 类型 | 描述 |
|-------------|-----|---------------------|
| method | str | 调用的方法名,get_overview |
| base_url | str | 基础路径 |
| org_sid | str | 项目组名称 |
| team_name | str | 团队唯一标识 |
| repo_id | str | 代码库id |
| project_id | str | 分析项目id |

##### 脚本内部参数
| Key | 类型 | Value |
|--|-----| - |
| Authorization | str | "Token 当前user的token" |

#### 3. 操作示例
```bash
python ScriptsAPI.py --base_url=${TCA_BASE_URL} --method=get_overview --org_sid=${TCA_ORG_SID} --team_name=${TCA_TEAM_NAME} --repo_id=${TCA_REPO_ID} --project_id=${TCA_PROJECT_ID}
```



### 七、查看扫描问题列表
#### 1. url请求
```
GET /server/analysis/api/orgs/<org_sid>/teams/<team_name>/repos/<repo_id>/projects/<project_id>/codelint/issues/
```
#### 2. 参数说明
##### 脚本参数

| 字段 | 类型 | 描述 |
|------------|-----|-------------------|
| method | str | 调用的方法名,get_issues |
| base_url | str | 基础路径 |
| org_sid | str | 项目组名称 |
| team_name | str | 团队唯一标识 |
| repo_id | str | 代码库id |
| project_id | str | 分析项目id |

##### 脚本内部参数
| Key | 类型 | Value |
|--|-----| - |
| Authorization | str | "Token 当前user的token" |

#### 3. 操作示例
```bash
python ScriptsAPI.py --base_url=${TCA_BASE_URL} --method=get_issues --org_sid=${TCA_ORG_SID} --team_name=${TCA_TEAM_NAME} --repo_id=${TCA_REPO_ID} --project_id=${TCA_PROJECT_ID}
```


### 八、查看问题详情
#### 1. url请求
```
GET /server/analysis/api/orgs/<org_sid>/teams/<team_name>/repos/<repo_id>/projects/<project_id>/codelint/issues/<issue_id>/
```
#### 2. 参数说明
##### 脚本参数

| 字段 | 类型 | 描述 |
|------------|-----|-------------------------|
| method | str | 调用的方法名,get_issue_detail |
| base_url | str | 基础路径 |
| org_sid | str | 项目组名称 |
| team_name | str | 团队唯一标识 |
| repo_id | str | 代码库id |
| project_id | str | 分析项目id |
| issue_id | str | 问题id |

##### 脚本内部参数
| Key | 类型 | Value |
|--|-----| - |
| Authorization | str | "Token 当前user的token" |

#### 3. 操作示例
```bash
python ScriptsAPI.py --base_url=${TCA_BASE_URL} --method=get_issue_detail --org_sid=${TCA_ORG_SID} --team_name=${TCA_TEAM_NAME} --repo_id=${TCA_REPO_ID} --project_id=${TCA_PROJECT_ID} --issue_id=${TCA_ISSUE_ID}
```


### 九、查看指定项目的圈复杂度问题列表
#### 1. url请求
```
GET /server/analysis/api/orgs/<org_sid>/teams/<team_name>/repos/<repo_id>/projects/<project_id>/codemetric/ccissues/
```
#### 2. 参数说明
##### 脚本参数

| 字段 | 类型 | 描述 |
|------------|-----|---------------------|
| method | str | 调用的方法名,get_ccissues |
| base_url | str | 基础路径 |
| org_sid | str | 项目组名称 |
| team_name | str | 团队唯一标识 |
| repo_id | str | 代码库id |
| project_id | str | 分析项目id |

##### 脚本内部参数
| Key | 类型 | Value |
|--|-----| - |
| Authorization | str | "Token 当前user的token" |

#### 3. 操作示例
```bash
python ScriptsAPI.py --base_url=${TCA_BASE_URL} --method=get_ccissues --org_sid=${TCA_ORG_SID} --team_name=${TCA_TEAM_NAME} --repo_id=${TCA_REPO_ID} --project_id=${TCA_PROJECT_ID}
```



### 十、查看指定项目的重复文件列表
#### 1. url请求
```
GET /server/analysis/api/orgs/<org_sid>/teams/<team_name>/repos/<repo_id>/projects/<project_id>/codemetric/dupfiles/
```
#### 2. 参数说明
##### 脚本参数

| 字段 | 类型 | 描述 |
|------------|-----|----------------------|
| method | str | 调用的方法名,get_dupfiles |
| base_url | str | 基础路径 |
| org_sid | str | 项目组名称 |
| team_name | str | 团队唯一标识 |
| repo_id | str | 代码库id |
| project_id | str | 分析项目id |

##### 脚本内部参数
| Key | 类型 | Value |
|--|-----| - |
| Authorization | str | "Token 当前user的token" |

#### 3. 操作示例
```bash
python ScriptsAPI.py --base_url=${TCA_BASE_URL} --method=get_dupfiles --org_sid=${TCA_ORG_SID} --team_name=${TCA_TEAM_NAME} --repo_id=${TCA_REPO_ID} --project_id=${TCA_PROJECT_ID}
```




Loading

0 comments on commit f32bef1

Please sign in to comment.