From 368bec25be453f499fa34fce30063a784d449196 Mon Sep 17 00:00:00 2001 From: small_leek Date: Sat, 19 Mar 2022 15:39:01 +0800 Subject: [PATCH 1/7] correct parameter's update() --- release-assistant/javcra/api/gitee_api_v8.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/release-assistant/javcra/api/gitee_api_v8.py b/release-assistant/javcra/api/gitee_api_v8.py index 4a731ea..1d5867c 100644 --- a/release-assistant/javcra/api/gitee_api_v8.py +++ b/release-assistant/javcra/api/gitee_api_v8.py @@ -335,10 +335,10 @@ class GiteeAPI(object): necessary_paras['issue_type_id'] = issue_type_id necessary_paras['assignee_id'] = assignee_id - final_paras = parameters.update(necessary_paras) - logger.info(final_paras) + parameters.update(necessary_paras) + logger.info(parameters) - result = self._post_gitee(url, final_paras) + result = self._post_gitee(url, parameters) try: issue_url = result['issue_url'] except KeyError as ke: -- Gitee From 994be0f5c51b04999a0ba60166314e123b7f3a47 Mon Sep 17 00:00:00 2001 From: jiangpengjuj Date: Wed, 7 Dec 2022 11:53:53 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E6=9B=B4=E6=96=B0jenkins=20=E5=9C=B0?= =?UTF-8?q?=E5=9D=80=EF=BC=8C=E5=B9=B6=E4=BF=AE=E6=94=B9=E5=8D=95=E5=85=83?= =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- release-assistant/javcra/common/constant.py | 2 +- .../test/test_check/mock_data/build_job_url.txt | 2 +- .../mock_data/create_build_jenkins_comments_success.txt | 8 ++++---- .../mock_data/create_install_jenkins_comments_success.txt | 2 +- .../test/test_release/mock_data/build_job_url.txt | 2 +- .../mock_data/delete_remain_epol_comments_success.txt | 2 +- .../mock_data/delete_remain_standard_comments_success.txt | 2 +- .../mock_data/publish_epol_comments_success.txt | 2 +- .../mock_data/publish_standard_comments_success.txt | 2 +- .../mock_data/create_bugfix_comments_success.txt | 2 +- 10 files changed, 13 insertions(+), 13 deletions(-) diff --git a/release-assistant/javcra/common/constant.py b/release-assistant/javcra/common/constant.py index ca30fd6..c479c30 100644 --- a/release-assistant/javcra/common/constant.py +++ b/release-assistant/javcra/common/constant.py @@ -123,7 +123,7 @@ INSTALL_JOB_PREFIX = "function-item/release-manager/update_template_jobs/install OBS_RELEASE_JOB = "obs/update_release_pkg_rpm" # jenkins base url -JENKINS_BASE_URL = 'https://jenkins.openeuler.org' +JENKINS_BASE_URL = 'https://openeulerjenkins.osinfra.cn' REALSE_TOOLS_BUCKET_NAME = "release-tools" diff --git a/release-assistant/test/test_check/mock_data/build_job_url.txt b/release-assistant/test/test_check/mock_data/build_job_url.txt index 01b79cb..e089385 100644 --- a/release-assistant/test/test_check/mock_data/build_job_url.txt +++ b/release-assistant/test/test_check/mock_data/build_job_url.txt @@ -1 +1 @@ -https://jenkins.openeuler.org/job/function-item/job/release-manager/job/release_tools/job/update_20210819094245/job/aarch64/job/openEuler-20.03-LTS-SP1_1/build \ No newline at end of file +https://openeulerjenkins.osinfra.cn/job/function-item/job/release-manager/job/release_tools/job/update_20210819094245/job/aarch64/job/openEuler-20.03-LTS-SP1_1/build \ No newline at end of file diff --git a/release-assistant/test/test_check/mock_data/create_build_jenkins_comments_success.txt b/release-assistant/test/test_check/mock_data/create_build_jenkins_comments_success.txt index 0659abd..7b50803 100644 --- a/release-assistant/test/test_check/mock_data/create_build_jenkins_comments_success.txt +++ b/release-assistant/test/test_check/mock_data/create_build_jenkins_comments_success.txt @@ -3,10 +3,10 @@ "id": 6274335, "body": "|name|status|output| |-|-|-| - |function-item/release-manager/release_tools/update_20210819094245/aarch64/openEuler-20.03-LTS-SP1_1|SUCCESS|[#1](https://jenkins.openeuler.org/job/function-item/job/release-manager/job/release_tools/job/update_20210819094245/job/aarch64/job/openEuler-20.03-LTS-SP1_1/1/console)| - |function-item/release-manager/release_tools/update_20210819094245/aarch64/openEuler-20.03-LTS-SP1_2|SUCCESS|[#1](https://jenkins.openeuler.org/job/function-item/job/release-manager/job/release_tools/job/update_20210819094245/job/aarch64/job/openEuler-20.03-LTS-SP1_1/1/console)| - |function-item/release-manager/release_tools/update_20210819094245/x86_64/openEuler-20.03-LTS-SP1_1|SUCCESS|[#1](https://jenkins.openeuler.org/job/function-item/job/release-manager/job/release_tools/job/update_20210819094245/job/aarch64/job/openEuler-20.03-LTS-SP1_1/1/console)| - |function-item/release-manager/release_tools/update_20210819094245/x86_64/openEuler-20.03-LTS-SP1_2|SUCCESS|[#1](https://jenkins.openeuler.org/job/function-item/job/release-manager/job/release_tools/job/update_20210819094245/job/aarch64/job/openEuler-20.03-LTS-SP1_1/1/console)|", + |function-item/release-manager/release_tools/update_20210819094245/aarch64/openEuler-20.03-LTS-SP1_1|SUCCESS|[#1](https://openeulerjenkins.osinfra.cn/job/function-item/job/release-manager/job/release_tools/job/update_20210819094245/job/aarch64/job/openEuler-20.03-LTS-SP1_1/1/console)| + |function-item/release-manager/release_tools/update_20210819094245/aarch64/openEuler-20.03-LTS-SP1_2|SUCCESS|[#1](https://openeulerjenkins.osinfra.cn/job/function-item/job/release-manager/job/release_tools/job/update_20210819094245/job/aarch64/job/openEuler-20.03-LTS-SP1_1/1/console)| + |function-item/release-manager/release_tools/update_20210819094245/x86_64/openEuler-20.03-LTS-SP1_1|SUCCESS|[#1](https://openeulerjenkins.osinfra.cn/job/function-item/job/release-manager/job/release_tools/job/update_20210819094245/job/aarch64/job/openEuler-20.03-LTS-SP1_1/1/console)| + |function-item/release-manager/release_tools/update_20210819094245/x86_64/openEuler-20.03-LTS-SP1_2|SUCCESS|[#1](https://openeulerjenkins.osinfra.cn/job/function-item/job/release-manager/job/release_tools/job/update_20210819094245/job/aarch64/job/openEuler-20.03-LTS-SP1_1/1/console)|", "user": { "id": 2234080, "login": "MementoMoriCheng", diff --git a/release-assistant/test/test_check/mock_data/create_install_jenkins_comments_success.txt b/release-assistant/test/test_check/mock_data/create_install_jenkins_comments_success.txt index 84524e4..2c26bb1 100644 --- a/release-assistant/test/test_check/mock_data/create_install_jenkins_comments_success.txt +++ b/release-assistant/test/test_check/mock_data/create_install_jenkins_comments_success.txt @@ -3,7 +3,7 @@ "id": 6274335, "body": "|name|status|output| |-|-|-| - |function-item/release-manager/openeuler-202106281604/test|SUCCESS|[#1](https://jenkins.openeuler.org/job/function-item/job/release-manager/job/release_tools/job/update_20210819094245/job/aarch64/job/openEuler-20.03-LTS-SP1_1/1/console)| + |function-item/release-manager/openeuler-202106281604/test|SUCCESS|[#1](https://openeulerjenkins.osinfra.cn/job/function-item/job/release-manager/job/release_tools/job/update_20210819094245/job/aarch64/job/openEuler-20.03-LTS-SP1_1/1/console)| ", "user": { "id": 2234080, diff --git a/release-assistant/test/test_release/mock_data/build_job_url.txt b/release-assistant/test/test_release/mock_data/build_job_url.txt index 01b79cb..e089385 100644 --- a/release-assistant/test/test_release/mock_data/build_job_url.txt +++ b/release-assistant/test/test_release/mock_data/build_job_url.txt @@ -1 +1 @@ -https://jenkins.openeuler.org/job/function-item/job/release-manager/job/release_tools/job/update_20210819094245/job/aarch64/job/openEuler-20.03-LTS-SP1_1/build \ No newline at end of file +https://openeulerjenkins.osinfra.cn/job/function-item/job/release-manager/job/release_tools/job/update_20210819094245/job/aarch64/job/openEuler-20.03-LTS-SP1_1/build \ No newline at end of file diff --git a/release-assistant/test/test_release/mock_data/delete_remain_epol_comments_success.txt b/release-assistant/test/test_release/mock_data/delete_remain_epol_comments_success.txt index 1c014df..59af54b 100644 --- a/release-assistant/test/test_release/mock_data/delete_remain_epol_comments_success.txt +++ b/release-assistant/test/test_release/mock_data/delete_remain_epol_comments_success.txt @@ -1,7 +1,7 @@ [ { "id": 6274335, - "body": "|name|status|output|\n|-|-|-|\n|obs/update_release_pkg_rpm|SUCCESS|[#1](https://jenkins.openeuler.org/job/function-item/job/release-manager/job/release_tools/job/update_20210819094245/job/aarch64/job/openEuler-20.03-LTS-SP1_1/1/console)|", + "body": "|name|status|output|\n|-|-|-|\n|obs/update_release_pkg_rpm|SUCCESS|[#1](https://openeulerjenkins.osinfra.cn/job/function-item/job/release-manager/job/release_tools/job/update_20210819094245/job/aarch64/job/openEuler-20.03-LTS-SP1_1/1/console)|", "user": { "id": 2234080, "login": "MementoMoriCheng", diff --git a/release-assistant/test/test_release/mock_data/delete_remain_standard_comments_success.txt b/release-assistant/test/test_release/mock_data/delete_remain_standard_comments_success.txt index 1c014df..59af54b 100644 --- a/release-assistant/test/test_release/mock_data/delete_remain_standard_comments_success.txt +++ b/release-assistant/test/test_release/mock_data/delete_remain_standard_comments_success.txt @@ -1,7 +1,7 @@ [ { "id": 6274335, - "body": "|name|status|output|\n|-|-|-|\n|obs/update_release_pkg_rpm|SUCCESS|[#1](https://jenkins.openeuler.org/job/function-item/job/release-manager/job/release_tools/job/update_20210819094245/job/aarch64/job/openEuler-20.03-LTS-SP1_1/1/console)|", + "body": "|name|status|output|\n|-|-|-|\n|obs/update_release_pkg_rpm|SUCCESS|[#1](https://openeulerjenkins.osinfra.cn/job/function-item/job/release-manager/job/release_tools/job/update_20210819094245/job/aarch64/job/openEuler-20.03-LTS-SP1_1/1/console)|", "user": { "id": 2234080, "login": "MementoMoriCheng", diff --git a/release-assistant/test/test_release/mock_data/publish_epol_comments_success.txt b/release-assistant/test/test_release/mock_data/publish_epol_comments_success.txt index 1c014df..59af54b 100644 --- a/release-assistant/test/test_release/mock_data/publish_epol_comments_success.txt +++ b/release-assistant/test/test_release/mock_data/publish_epol_comments_success.txt @@ -1,7 +1,7 @@ [ { "id": 6274335, - "body": "|name|status|output|\n|-|-|-|\n|obs/update_release_pkg_rpm|SUCCESS|[#1](https://jenkins.openeuler.org/job/function-item/job/release-manager/job/release_tools/job/update_20210819094245/job/aarch64/job/openEuler-20.03-LTS-SP1_1/1/console)|", + "body": "|name|status|output|\n|-|-|-|\n|obs/update_release_pkg_rpm|SUCCESS|[#1](https://openeulerjenkins.osinfra.cn/job/function-item/job/release-manager/job/release_tools/job/update_20210819094245/job/aarch64/job/openEuler-20.03-LTS-SP1_1/1/console)|", "user": { "id": 2234080, "login": "MementoMoriCheng", diff --git a/release-assistant/test/test_release/mock_data/publish_standard_comments_success.txt b/release-assistant/test/test_release/mock_data/publish_standard_comments_success.txt index 1c014df..59af54b 100644 --- a/release-assistant/test/test_release/mock_data/publish_standard_comments_success.txt +++ b/release-assistant/test/test_release/mock_data/publish_standard_comments_success.txt @@ -1,7 +1,7 @@ [ { "id": 6274335, - "body": "|name|status|output|\n|-|-|-|\n|obs/update_release_pkg_rpm|SUCCESS|[#1](https://jenkins.openeuler.org/job/function-item/job/release-manager/job/release_tools/job/update_20210819094245/job/aarch64/job/openEuler-20.03-LTS-SP1_1/1/console)|", + "body": "|name|status|output|\n|-|-|-|\n|obs/update_release_pkg_rpm|SUCCESS|[#1](https://openeulerjenkins.osinfra.cn/job/function-item/job/release-manager/job/release_tools/job/update_20210819094245/job/aarch64/job/openEuler-20.03-LTS-SP1_1/1/console)|", "user": { "id": 2234080, "login": "MementoMoriCheng", diff --git a/release-assistant/test/test_start/mock_data/create_bugfix_comments_success.txt b/release-assistant/test/test_start/mock_data/create_bugfix_comments_success.txt index 84524e4..2c26bb1 100644 --- a/release-assistant/test/test_start/mock_data/create_bugfix_comments_success.txt +++ b/release-assistant/test/test_start/mock_data/create_bugfix_comments_success.txt @@ -3,7 +3,7 @@ "id": 6274335, "body": "|name|status|output| |-|-|-| - |function-item/release-manager/openeuler-202106281604/test|SUCCESS|[#1](https://jenkins.openeuler.org/job/function-item/job/release-manager/job/release_tools/job/update_20210819094245/job/aarch64/job/openEuler-20.03-LTS-SP1_1/1/console)| + |function-item/release-manager/openeuler-202106281604/test|SUCCESS|[#1](https://openeulerjenkins.osinfra.cn/job/function-item/job/release-manager/job/release_tools/job/update_20210819094245/job/aarch64/job/openEuler-20.03-LTS-SP1_1/1/console)| ", "user": { "id": 2234080, -- Gitee From fbef95dc58922435c80568f30b8a64dcb8aea671 Mon Sep 17 00:00:00 2001 From: gitee-cmd Date: Thu, 3 Nov 2022 22:42:37 +0800 Subject: [PATCH 3/7] local implemetnt of release tools --- release-assistant/javcra/api/gitee_api.py | 41 ++++++- release-assistant/javcra/api/gitee_comment.py | 69 +++++++++++- .../javcra/application/serialize/serialize.py | 1 + .../application/startpart/startentrance.py | 2 +- release-assistant/javcra/cli/cmd.py | 2 + .../javcra/cli/commands/checkpart.py | 27 ++++- .../javcra/cli/commands/createpart.py | 59 +++++++++++ release-assistant/javcra/common/constant.py | 20 +++- release-assistant/javcra/create_release.py | 100 ++++++++++++++++++ .../yum.repo/openEuler-20.03-LTS-SP1.repo | 4 +- .../yum.repo/openEuler-20.03-LTS-SP3.repo | 2 +- .../yum.repo/openEuler-22.03-LTS.repo | 2 +- release-assistant/test/base/basetest.py | 1 + .../test/mock_data/checkpart.txt | 4 +- .../expected_data/create_comment_failed.txt | 2 +- .../expected_data/download_pkg_log_failed.txt | 4 - .../expected_data/requires_success.txt | 3 - ...back_create_install_build_issue_failed.txt | 4 - ...rite_back_operate_release_issue_failed.txt | 4 - .../test_check/mock_data/check_epol_list.txt | 4 +- .../test_check/mock_data/repo_list_data.txt | 4 +- .../mock_data/single_exist_issues.txt | 4 +- .../test_template_config_aarch64.xml | 4 +- .../mock_data/test_template_config_x86.xml | 4 +- .../test/test_check/test_check_cli.py | 36 +++---- .../test_modify/mock_data/add_issue_info.txt | 4 +- .../test_modify/mock_data/mock_issue_abi.txt | 4 +- .../mock_data/mock_issue_basescore.txt | 4 +- .../mock_data/mock_issue_no_score.txt | 4 +- .../mock_data/mock_remain_issue_1_data.txt | 4 +- .../mock_data/mock_remain_issue_2_data.txt | 4 +- 31 files changed, 354 insertions(+), 77 deletions(-) create mode 100644 release-assistant/javcra/cli/commands/createpart.py create mode 100644 release-assistant/javcra/create_release.py diff --git a/release-assistant/javcra/api/gitee_api.py b/release-assistant/javcra/api/gitee_api.py index 62fffad..387d16e 100644 --- a/release-assistant/javcra/api/gitee_api.py +++ b/release-assistant/javcra/api/gitee_api.py @@ -89,6 +89,12 @@ class Issue: return None return resp + def externel_gitee_api_url(self, url_name, **kwargs): + """ + Description: externel usage of gitee url api + """ + return self.__get_gitee_api_url(url_name, **kwargs) + def __get_gitee_api_url(self, url_name, **kwargs): """ get specific gitee api url @@ -102,7 +108,6 @@ class Issue: """ url_prefix = "https://gitee.com/api/v5/" - url_dict = { "pkg_issues_url": url_prefix + "repos/{owner}/{repo}/issues?access_token={access_token}&state=all" .format(owner=self.owner, repo=kwargs.get("pkg"), access_token=self.token), @@ -115,6 +120,9 @@ class Issue: "update_issue_url": url_prefix + "repos/{owner}/issues/{number}".format(owner=kwargs.get("owner"), number=self.issue_num), + "get_issue_url": url_prefix + "repos/{owner}/release-tools/issues/{number}?access_token={token}".format( + owner=kwargs.get("owner"), number=kwargs.get("issue_id"), token=self.token), + "create_comment_url": url_prefix + "repos/{owner}/{repo}/issues/{number}/comments".format( owner=kwargs.get("owner"), repo=self.repo, number=self.issue_num), @@ -129,7 +137,6 @@ class Issue: "".format(owner=kwargs.get("owner"), repo=kwargs.get("repo"), number=kwargs.get("issue_id"), token=self.token) } - return url_dict.get(url_name) def __get_pkg_issues(self, pkg): @@ -480,6 +487,36 @@ class Issue: pkglist_epol.append(pkg) return pkglist_standard, pkglist_epol + def get_issue_tables(self): + """ + use regex to get bugfix and cve tables + + Args: + issue_body: issue body str + + Returns: + str: string of bugfix and cve tables + """ + issue_body = self.get_issue_body(self.issue_num) + + if not issue_body: + logger.error("empty content of issue body, can not get update list.") + return [] + + pkgs = set() + + # using regular to get the contents of the specified part + cve_res = re.compile("(?P1、CVE.*?\\n\\n)", re.S).search(issue_body) + bugfix_res = re.compile("(?P2、bugfix.*?\\n\\n)", re.S).search(issue_body) + req_res = re.compile("(?P3、requires.*?\\n\\n)", re.S).search(issue_body) + + # get packages from cve、bugfix、requires table + pkgs = self.__get_pkglist_from_specific_part(cve_res, "cve", pkgs) + pkgs = self.__get_pkglist_from_specific_part(bugfix_res, "bugfix", pkgs) + pkgs = self.__get_pkglist_from_specific_part(req_res, "req", pkgs) + + return list(pkgs) + def get_issue_comments(self, params): """ get comments according to params diff --git a/release-assistant/javcra/api/gitee_comment.py b/release-assistant/javcra/api/gitee_comment.py index cd78631..b3a6013 100644 --- a/release-assistant/javcra/api/gitee_comment.py +++ b/release-assistant/javcra/api/gitee_comment.py @@ -13,18 +13,20 @@ """ add a comment for the address of jenkins in the comment section of issue """ +import csv import sys import os import argparse from datetime import datetime - -ABSPATH = os.path.dirname(os.path.dirname(os.path.abspath(os.path.realpath(os.path.dirname(__file__))))) -sys.path.insert(0, ABSPATH) from javcra.application.modifypart.modifyentrance import IssueOperation from javcra.api.jenkins_api import JenkinsJob -from javcra.common.constant import GITEE_REPO, JENKINS_BASE_URL, LTS_BRANCH, MAX_PARAL_NUM +from javcra.common.constant import GITEE_REPO, JENKINS_BASE_URL, LTS_BRANCH, MAX_PARAL_NUM, VERSION_TABLE_HEADER +from javcra.common.constant import CHECK_RESULT_CSV_PATH from javcra.libs.log import logger +ABSPATH = os.path.dirname(os.path.dirname(os.path.abspath(os.path.realpath(os.path.dirname(__file__))))) +sys.path.insert(0, ABSPATH) + class Comment(IssueOperation, JenkinsJob): """ @@ -63,6 +65,50 @@ class Comment(IssueOperation, JenkinsJob): return False return True + def version_check_comment(self, init_path): + """ + add a comment for the result of the check versions. + Args: + init_path: path of the check result + + Returns: + comment_res: comment response + """ + csv_path = os.path.join(init_path, CHECK_RESULT_CSV_PATH) + if os.path.getsize(csv_path) == 0: + comment_content = self.init_md_table(["packages_version_check_Result"], + [{"packages_version_check_Result": "All packages up to date."}]) + else: + with open(csv_path, "r") as version_file: + reader = csv.reader(version_file) + table_body = self.version_table_generator(reader) + comment_content = self.init_md_table(VERSION_TABLE_HEADER, table_body) + comment_res = self.create_issue_comment(comment_content) + if not comment_res: + logger.error("Failed to create Jenkins' comment message %s" % comment_res) + return False + return True + + def version_table_generator(self, reader): + """ + Generate version info of packages on gitee and obs. + Args: + reader: cvs reader + Returns: + list: list of packages' version + """ + table_body = [] + for row in reader: + table_comment = {VERSION_TABLE_HEADER[0]: row[1], # package_name + VERSION_TABLE_HEADER[1]: row[2], # gitee-sp1 version + VERSION_TABLE_HEADER[2]: row[3], # obs-sp1 version + VERSION_TABLE_HEADER[3]: row[5], # gitee-sp3 version + VERSION_TABLE_HEADER[4]: row[6], # obs-sp3 version + VERSION_TABLE_HEADER[5]: row[8], # gitee-sp2203 version + VERSION_TABLE_HEADER[6]: row[9]} # obs-sp2203 version + table_body.append(table_comment) + return table_body + if __name__ == '__main__': parser = argparse.ArgumentParser(description="create gitee comments") @@ -72,10 +118,23 @@ if __name__ == '__main__': parser.add_argument("--jenkins_password", required=True, type=str, help="jenkins password") parser.add_argument("--jenkins_job_name", required=True, type=str, help="jenkins job name") parser.add_argument("--build_id", required=True, type=int, help="build id") + parser.add_argument("--init_path", required=False, type=str, help="init path of the jenkins job") + + parser.add_argument("--comment_type", + required=False, + type=str, + help="comment_type", + default="normal", + choices=["normal", "check"]) + args = parser.parse_args() create_time = datetime.now().strftime("%Y-%m-%d") comment = Comment(GITEE_REPO, args.token, args.issue_num, JENKINS_BASE_URL, args.jenkins_user, args.jenkins_password, create_time) - resp = comment.create_comment(args.jenkins_job_name, args.build_id) + + if args.comment_type == "normal": + resp = comment.create_comment(args.jenkins_job_name, args.build_id) + else: + resp = comment.version_check_comment(args.init_path) if resp: print("Successfully created an issue about jenkins information comment") diff --git a/release-assistant/javcra/application/serialize/serialize.py b/release-assistant/javcra/application/serialize/serialize.py index 15e19cd..b60ad8f 100644 --- a/release-assistant/javcra/application/serialize/serialize.py +++ b/release-assistant/javcra/application/serialize/serialize.py @@ -50,6 +50,7 @@ class CheckSchema(BaseSchema): sk = fields.String(required=False, validate=validate.Length(min=1)) jenkinsuser = fields.String(required=False, validate=validate.Length(min=1)) jenkinskey = fields.String(required=False, validate=validate.Length(min=1)) + buildcheck = fields.Boolean(required=False) class ModifySchema(BaseSchema): diff --git a/release-assistant/javcra/application/startpart/startentrance.py b/release-assistant/javcra/application/startpart/startentrance.py index bdf0edd..54f5e2c 100644 --- a/release-assistant/javcra/application/startpart/startentrance.py +++ b/release-assistant/javcra/application/startpart/startentrance.py @@ -37,4 +37,4 @@ class StartEntrance(): """ print("start release part!") - pass \ No newline at end of file + pass diff --git a/release-assistant/javcra/cli/cmd.py b/release-assistant/javcra/cli/cmd.py index e3d6ccd..6afb2cf 100644 --- a/release-assistant/javcra/cli/cmd.py +++ b/release-assistant/javcra/cli/cmd.py @@ -17,11 +17,13 @@ Class: JavcraCommand from javcra.cli.base import BaseCommand from javcra.common.exc import Error + # 'import xxxxCommand' would be used in the args_parser() to register command from javcra.cli.commands.startpart import StartCommand # pylint: disable=unused-import from javcra.cli.commands.releasepart import ReleaseCommand # pylint: disable=unused-import from javcra.cli.commands.modifypart import ModifyCommand # pylint: disable=unused-import from javcra.cli.commands.checkpart import CheckCommand # pylint: disable=unused-import +from javcra.cli.commands.createpart import CreateCommand # pylint: disable=unused-import def main(): diff --git a/release-assistant/javcra/cli/commands/checkpart.py b/release-assistant/javcra/cli/commands/checkpart.py index 495895a..c2cc682 100644 --- a/release-assistant/javcra/cli/commands/checkpart.py +++ b/release-assistant/javcra/cli/commands/checkpart.py @@ -15,6 +15,7 @@ Description: check method's entrance for custom commands Class:CheckCommand """ import os +import stat import uuid from javcra.api.jenkins_api import JenkinsJob from javcra.application.checkpart.checkentrance import CheckEntrance @@ -165,7 +166,7 @@ class CheckCommand(BaseCommand): Returns: True or False """ - comment_params = {"owner": "openEuler", "repo": GITEE_REPO, "issue_id": params.releaseIssueID} + comment_params = {"owner": "openeuler", "repo": GITEE_REPO, "issue_id": params.releaseIssueID} comment_list = [COMMENT_DICT.get("cve"), COMMENT_DICT.get("bugfix")] judge_res = issue.judge_specific_comment_exists(comment_list, comment_params) if not judge_res: @@ -302,6 +303,26 @@ class CheckCommand(BaseCommand): str(uuid.uuid1().hex))) return self.read_log_data(cloud_server, pkg_log, tem_pkg_log_path, pkg_name) + def versions_operation(self, params): + """ + Description: operation for check the version of pacakges + Args: + params: Command line parameters + """ + issue = self.issue(params) + judege_res = self.judge_cve_bugfix_comment(issue, params) + if not judege_res: + return + + update_pkgs = issue.get_update_list() + if not update_pkgs: + raise ValueError("failed to get obs_pkgs.") + flags = os.O_WRONLY | os.O_CREAT | os.O_EXCL + modes = stat.S_IWUSR | stat.S_IRUSR + with os.fdopen(os.open('update_packages.txt', flags, modes), 'w') as f: + for pkg in update_pkgs: + f.write("{}\n".format(pkg)) + def requires_operation(self, params): """ Description: operation for get requires @@ -446,10 +467,9 @@ class CheckCommand(BaseCommand): if not add_res: raise ValueError("failed to add repo in release issue.") print("[INFO] successful to add repo in release issue.") - + if not params.buildcheck: return - # self-build verification selfbuild_res = verify_selfbuild() self.create_comment("selfbuild jenkins res", selfbuild_res, issue) @@ -490,6 +510,7 @@ class CheckCommand(BaseCommand): "sk": params.sk, "jenkinsuser": params.jenkinsuser, "jenkinskey": params.jenkinskey, + "buildcheck": params.buildcheck } validate_result = parameter_permission_validate( CheckSchema, param_dict, comment diff --git a/release-assistant/javcra/cli/commands/createpart.py b/release-assistant/javcra/cli/commands/createpart.py new file mode 100644 index 0000000..95b1401 --- /dev/null +++ b/release-assistant/javcra/cli/commands/createpart.py @@ -0,0 +1,59 @@ +#!/usr/bin/python3 +# ****************************************************************************** +# Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. +# licensed under the Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan PSL v2. +# You may obtain a copy of Mulan PSL v2 at: +# http://license.coscl.org.cn/MulanPSL2 +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR +# PURPOSE. +# See the Mulan PSL v2 for more details. +# ******************************************************************************/ +""" +Description: start method's entrance for custom commands +Class:StartCommand +""" + +from javcra.create_release import UpdateIssue +from javcra.cli.base import BaseCommand +from javcra.common.constant import GITEE_REPO, LABEL_DICT +from javcra.libs.log import logger + + +class CreateCommand(BaseCommand): + """ + Description: start the release assistant + Attributes: + sub_parse: Subcommand parameters + params: Command line parameters + """ + + def __init__(self): + """ + Description: Instance initialization + """ + super(CreateCommand, self).__init__() + self.sub_parse = BaseCommand.subparsers.add_parser( + "create", help="command to create release issue") + + self.sub_parse.add_argument( + "--token", + type=str, + help="a valid GiteeToken value", + action="store", + required=True, + ) + + def do_command(self, params): + """ + Description: Executing command + Args: + params: Command line parameters + """ + issue = UpdateIssue(GITEE_REPO, params.token) + create_res = issue.create_update_release() + if create_res: + logger.info("create release successfully.") + else: + logger.error("failed to create release.") diff --git a/release-assistant/javcra/common/constant.py b/release-assistant/javcra/common/constant.py index ca30fd6..60b8559 100644 --- a/release-assistant/javcra/common/constant.py +++ b/release-assistant/javcra/common/constant.py @@ -47,7 +47,8 @@ PERMISSION_INFO = { "/bugfix-ok", "/check-status", "/get-requires", - "/check-cve-bugfix" + "/check-cve-bugfix", + "/check-versions" ], "tester": ["/test-ok"], "tc": ["/check-ok"], @@ -73,7 +74,7 @@ AARCH_FRAME = "aarch64" X86_FRAME = "x86_64" # branch list for standard epol list -BRANCH_LIST = ["openEuler-20.03-LTS-SP1", "openEuler-20.03-LTS-SP2", "openEuler-20.03-LTS-SP3", "openEuler-20.03-LTS", "openEuler-22.03-LTS"] +BRANCH_LIST = ["openEuler-20.03-LTS-SP1", "openEuler-20.03-LTS-SP3", "openEuler-22.03-LTS"] # lts branch LTS_BRANCH = "openEuler-20.03-LTS" @@ -140,7 +141,8 @@ CHECK_COMMENT_DICT = { "status": "/check-status", "requires": "/get-requires", "test": "/test-ok", - "cve_bugfix": "/check-cve-bugfix" + "cve_bugfix": "/check-cve-bugfix", + "versions": "/check-versions" } # release url @@ -162,4 +164,14 @@ LABEL_DICT = {"start": "check-pkg", "requires": "check-requires", "release": "re MULTI_VERSION_BRANCHS = ["sp2", "sp3", "SP2", "SP3"] -CHECK_PART_LIST = ["status", "requires", "test", "cve_bugfix"] +CHECK_PART_LIST = ["status", "requires", "test", "cve_bugfix", "versions"] + +VERSION_TABLE_HEADER = ["package_name", "gitee-sp1", "obs-sp1", "gitee-sp3", "obs-sp3", "gitee-sp2203", "obs-sp2203"] + +CHECK_RESULT_CSV_PATH = "update_packages2/src/check_result.csv" + +#staff +VERSION_MANAGER = "@gitee-cmd @zhangtao2020" +DEVELOPER = "@gitee-cmd @zhangtao2020 @caodongxia @yaoxin" +SECURITY_COMMITTEE = "@yanxiaobing2020 @gitee-cmd @zhangtao2020" +TESTER = "@gitee-cmd @zhangtao2020 @disnight" diff --git a/release-assistant/javcra/create_release.py b/release-assistant/javcra/create_release.py new file mode 100644 index 0000000..6bef179 --- /dev/null +++ b/release-assistant/javcra/create_release.py @@ -0,0 +1,100 @@ +#!/usr/bin/python3 +# ****************************************************************************** +# Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. +# licensed under the Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan PSL v2. +# You may obtain a copy of Mulan PSL v2 at: +# http://license.coscl.org.cn/MulanPSL2 +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR +# PURPOSE. +# See the Mulan PSL v2 for more details. +# ******************************************************************************/ +""" +Description: start commands entrance +Class: StartEntrance +""" +import json +from datetime import datetime, timedelta, timezone +from javcra.api.gitee_api import Issue +from javcra.common.constant import BRANCH_LIST, VERSION_MANAGER, DEVELOPER, SECURITY_COMMITTEE, TESTER +from javcra.libs.log import logger + + +class UpdateIssue(Issue): + def __init__(self, repo, token, issue_num): + super().__init__(repo, token, issue_num=None) + + def create_update_issue(self, branch): + """ + Description: create update issues automatically. + Args: + branch: branch name of openEuler in src-openEuler + + Returns: + params(dict):dictionary of issue body + """ + base_date = (datetime.now(tz=timezone.utc) + timedelta(hours=8)) + release_date = base_date.strftime('%Y/%m/%d') + frozen_date = (base_date + timedelta(days=2)).strftime('%Y%m%d') + params = { + "repo": self.repo, + "owner": "openeuler", + "access_token": self.token, + "title": "{brh} Update {release_date} release".format(brh=branch, release_date=release_date)} + + remind_str = "说明:此issue为机器自动创建update发布issue" + params["body"] = "版本目标: CVE、软件包引入升级和Bugfix修复\n版本: {brh}\n例行CVE冻结: {frozen_date}\n" \ + "代码冻结: {frozen_date}\n\n版本发布负责人\n版本经理:{vm}\n开发人员:{dev}\n" \ + "安全委员会:{sec}\n测试人员:{te}\n\n" \ + .format(brh=branch, frozen_date=frozen_date, vm=VERSION_MANAGER, + dev=DEVELOPER, sec=SECURITY_COMMITTEE, te=TESTER, remind_str=remind_str) + return params + + def create_issue(self, data): + """ + Description: create issue in gitee + Args: + data: data to create issue + + Returns: + created_issue_id(str) + """ + # get all the open state issue's title + issue_title = data.get("title") + + prj_issue_url = self.externel_gitee_api_url("create_issue_url", owner=data["owner"]) + post_res = self.gitee_api_request("post", prj_issue_url, data=data) + if not post_res: + logger.error("failed to create the issue: {}".format(issue_title)) + return "error_issue_id" + + resp_content = json.loads(post_res.text) + created_issue_id = resp_content["number"] + logger.info("an issue with %s id has been created" % created_issue_id) + return created_issue_id + + def create_update_release(self): + """ + Description: create release issues of all branches + Returns: + boolean + """ + release_issue_dict = {} + for branch in BRANCH_LIST: + params = self.create_update_issue(branch) + if len(params['body']) == 204: # length of the template body + release_issue_dict[branch] = "error_issue_id" + logger.error("%s create failed due to invalid issue body", branch) + continue + + issue_id = self.create_issue(params) + if issue_id == "error_issue_id": + logger.error("%s create issue failed, please try again, please check", branch) + release_issue_dict[branch] = issue_id + + if all(_ == "error_issue_id" for _ in release_issue_dict.values()): + logger.error("All branches created failed, please check former errors,") + return False + logger.info("The result of issue is: {}".format(release_issue_dict)) + return True diff --git a/release-assistant/javcra/libs/config/checkpart/check_requires/yum.repo/openEuler-20.03-LTS-SP1.repo b/release-assistant/javcra/libs/config/checkpart/check_requires/yum.repo/openEuler-20.03-LTS-SP1.repo index d3332c1..c88ad74 100644 --- a/release-assistant/javcra/libs/config/checkpart/check_requires/yum.repo/openEuler-20.03-LTS-SP1.repo +++ b/release-assistant/javcra/libs/config/checkpart/check_requires/yum.repo/openEuler-20.03-LTS-SP1.repo @@ -78,9 +78,9 @@ enabled=0 gpgcheck=0 gpgkey=https://repo.openeuler.org/openEuler-20.03-LTS-SP1/EPOL/update/source/RPM-GPG-KEY-openEuler -[devel-obs] +[devel-Epol-obs] name=devel-obs -baseurl=http://119.3.219.20:82/openEuler:/20.03:/LTS:/SP1/standard_$basearch/ +baseurl=http://119.3.219.20:82/openEuler:/20.03:/LTS:/SP1:/Epol/standard_$basearch/ enabled=1 gpgcheck=0 priority=3 diff --git a/release-assistant/javcra/libs/config/checkpart/check_requires/yum.repo/openEuler-20.03-LTS-SP3.repo b/release-assistant/javcra/libs/config/checkpart/check_requires/yum.repo/openEuler-20.03-LTS-SP3.repo index 41cc149..0892a29 100644 --- a/release-assistant/javcra/libs/config/checkpart/check_requires/yum.repo/openEuler-20.03-LTS-SP3.repo +++ b/release-assistant/javcra/libs/config/checkpart/check_requires/yum.repo/openEuler-20.03-LTS-SP3.repo @@ -80,7 +80,7 @@ gpgkey=https://repo.openeuler.org/openEuler-20.03-LTS-SP3/EPOL/update/main/sourc [devel-obs] name=devel-obs -baseurl=http://119.3.219.20:82/openEuler:/20.03:/LTS:/SP3/standard_$basearch/ +baseurl=http://119.3.219.20:82/openEuler:/20.03:/LTS:/SP3:/Epol/standard_$basearch/ enabled=1 gpgcheck=0 priority=3 diff --git a/release-assistant/javcra/libs/config/checkpart/check_requires/yum.repo/openEuler-22.03-LTS.repo b/release-assistant/javcra/libs/config/checkpart/check_requires/yum.repo/openEuler-22.03-LTS.repo index ae2a19d..4296ed0 100644 --- a/release-assistant/javcra/libs/config/checkpart/check_requires/yum.repo/openEuler-22.03-LTS.repo +++ b/release-assistant/javcra/libs/config/checkpart/check_requires/yum.repo/openEuler-22.03-LTS.repo @@ -80,7 +80,7 @@ gpgkey=https://repo.openeuler.org/openEuler-22.03-LTS/EPOL/update/main/source/RP [devel-obs] name=devel-obs -baseurl=http://119.3.219.20:82/openEuler:/22.03:/LTS/standard_$basearch/ +baseurl=http://119.3.219.20:82/openEuler:/22.03:/LTS:/Epol/standard_$basearch/ enabled=1 gpgcheck=0 priority=3 diff --git a/release-assistant/test/base/basetest.py b/release-assistant/test/base/basetest.py index 5151355..b1637e6 100644 --- a/release-assistant/test/base/basetest.py +++ b/release-assistant/test/base/basetest.py @@ -67,6 +67,7 @@ class TestBase(unittest.TestCase): self.stdout_io = StringIO() self.expect_str = "" self.command_params = [] + self.maxDiff = None sys.stdout = sys.stderr = self.stdout_io def _execute_command(self): diff --git a/release-assistant/test/mock_data/checkpart.txt b/release-assistant/test/mock_data/checkpart.txt index 531ee20..e485b63 100644 --- a/release-assistant/test/mock_data/checkpart.txt +++ b/release-assistant/test/mock_data/checkpart.txt @@ -10,7 +10,7 @@ "parent_id": 0, "depth": 0, "state": "open", - "title": "openEuler-20.03-LTS Update 2021/7/29 release", + "title": "openEuler-20.03-LTS-SP1 Update 2021/7/29 release", "body": "版本目标:CVE、软件包引入升级和Bugfix修复\n版本:openEuler-20.03-LTS-SP1\n例行CVE冻结:20210420\n代码冻结:20210420\n\n版本发布负责人\n版本经理:@Mary\n开发人员:@Mary@Jerry\n安全委员会:@Mary@Ben\n测试人员:@Mary@Harry@Robin\n\n# 1、发布范围\n## 1、CVE\n修复CVE 2个\n|CVE|仓库|status|score|version|abi是否变化|\n|-|-|-|-|-|-|\n|#I3V9IG|libvma|遗留|9.0|10.3.9|否|\n|#I3OC6A|jetty|遗留|9.8|3.2.1|否|\n\n\n\n## 2、bugfix\n修复bugfix 1个\n|issue|仓库|status|\n|-|-|-|\n|#I3J655|httpd|遗留|\n\n\n## 3、requires\n|仓库|引入原因|\n|-|-|\n|bluez|接口变更|\n|edk2|升级|\n\n# 2、测试repo源\n|repo_type|architecture|url|\n|-|-|-|\n\n\n# 3、安装、自编译问题\n|issue|仓库|status|\n|-|-|-|\n|#I3TFOK|httpd|遗留|\n\n# 4、遗留问题\n|issue|仓库|status|type|\n|-|-|-|-|\n\n", "user": { "id": 2234080, @@ -150,4 +150,4 @@ "security_hole": false, "issue_state": "待办的", "branch": null -} \ No newline at end of file +} diff --git a/release-assistant/test/test_check/expected_data/create_comment_failed.txt b/release-assistant/test/test_check/expected_data/create_comment_failed.txt index ab14525..bf7c490 100644 --- a/release-assistant/test/test_check/expected_data/create_comment_failed.txt +++ b/release-assistant/test/test_check/expected_data/create_comment_failed.txt @@ -3,4 +3,4 @@ already exists the repo url, then update the pkglist in repo. [ERROR] failed to create transfer standard rpm jenkins res [INFO] successful to add repo in release issue. [ERROR] failed to create selfbuild jenkins res -[ERROR] failed to create standard install jenkins res \ No newline at end of file +[ERROR] failed to create standard install jenkins res diff --git a/release-assistant/test/test_check/expected_data/download_pkg_log_failed.txt b/release-assistant/test/test_check/expected_data/download_pkg_log_failed.txt index 666921b..664992f 100644 --- a/release-assistant/test/test_check/expected_data/download_pkg_log_failed.txt +++ b/release-assistant/test/test_check/expected_data/download_pkg_log_failed.txt @@ -2,7 +2,3 @@ already exists the repo url, then update the pkglist in repo. [INFO] successfully create transfer standard rpm jenkins res [INFO] successful to add repo in release issue. -[INFO] successfully create selfbuild jenkins res -[INFO] successfully create standard install jenkins res -failed to write back to install_build issue I45XDF in release issue -failed to create install_list issue for a-test. \ No newline at end of file diff --git a/release-assistant/test/test_check/expected_data/requires_success.txt b/release-assistant/test/test_check/expected_data/requires_success.txt index 0a38c61..3283c7a 100644 --- a/release-assistant/test/test_check/expected_data/requires_success.txt +++ b/release-assistant/test/test_check/expected_data/requires_success.txt @@ -3,6 +3,3 @@ already exists the repo url, then update the pkglist in repo. [INFO] successfully create transfer standard rpm jenkins res [INFO] successfully create transfer epol rpm jenkins res [INFO] successful to add repo in release issue. -[INFO] successfully create selfbuild jenkins res -[INFO] successfully create standard install jenkins res -[INFO] successfully create epol install jenkins res \ No newline at end of file diff --git a/release-assistant/test/test_check/expected_data/write_back_create_install_build_issue_failed.txt b/release-assistant/test/test_check/expected_data/write_back_create_install_build_issue_failed.txt index 78b46b4..664992f 100644 --- a/release-assistant/test/test_check/expected_data/write_back_create_install_build_issue_failed.txt +++ b/release-assistant/test/test_check/expected_data/write_back_create_install_build_issue_failed.txt @@ -2,7 +2,3 @@ already exists the repo url, then update the pkglist in repo. [INFO] successfully create transfer standard rpm jenkins res [INFO] successful to add repo in release issue. -[INFO] successfully create selfbuild jenkins res -[INFO] successfully create standard install jenkins res -failed to create build_list issue for a-test. -failed to create install_list issue for a-test. \ No newline at end of file diff --git a/release-assistant/test/test_check/expected_data/write_back_operate_release_issue_failed.txt b/release-assistant/test/test_check/expected_data/write_back_operate_release_issue_failed.txt index b1b585f..664992f 100644 --- a/release-assistant/test/test_check/expected_data/write_back_operate_release_issue_failed.txt +++ b/release-assistant/test/test_check/expected_data/write_back_operate_release_issue_failed.txt @@ -2,7 +2,3 @@ already exists the repo url, then update the pkglist in repo. [INFO] successfully create transfer standard rpm jenkins res [INFO] successful to add repo in release issue. -[INFO] successfully create selfbuild jenkins res -[INFO] successfully create standard install jenkins res -failed to write back to install_build issue I46DHK in release issue -failed to write back to install_build issue I47FFK in release issue \ No newline at end of file diff --git a/release-assistant/test/test_check/mock_data/check_epol_list.txt b/release-assistant/test/test_check/mock_data/check_epol_list.txt index 15b1594..e855f3b 100644 --- a/release-assistant/test/test_check/mock_data/check_epol_list.txt +++ b/release-assistant/test/test_check/mock_data/check_epol_list.txt @@ -10,7 +10,7 @@ "parent_id": 0, "depth": 0, "state": "open", - "title": "openEuler-20.03-LTS Update 2021/7/29 release", + "title": "openEuler-20.03-LTS-SP1 Update 2021/7/29 release", "body": "版本目标:CVE、软件包引入升级和Bugfix修复\n版本:openEuler-20.03-LTS-SP1\n例行CVE冻结:20210420\n代码冻结:20210420\n\n版本发布负责人\n 版本经理:@Mary \n开发人员:@Mary@Jerry \n安全委员会:@Mary@Ben \n测试人员:@Mary@Harry@Robin \n\n# 1、发布范围\n## 1、CVE\n修复CVE 1个\n|CVE|仓库|status|score|version|abi是否变化|\n|-|-|-|-|-|-|\n|#I3V9IG|atril|遗留|9.0|10.3.9|否|\n|\n\n\n## 2、bugfix\n修复bugfix 1个\n|issue|仓库|status|\n|-|-|-|\n|#I3J655|bamf|遗留|\n\n\n## 3、requires\n|仓库|引入原因|\n|-|-|\n|blueman|接口变更|\n\n\n# 2、测试repo源\n|repo_type|architecture|url|\n|-|-|-|\n\n\n# 3、安装、自编译问题\n|issue|仓库|status|\n|-|-|-|\n\n\n# 4、遗留问题\n|issue|仓库|status|type|\n|-|-|-|-|\n\n", "user": { "id": 2234080, @@ -150,4 +150,4 @@ "security_hole": false, "issue_state": "待办的", "branch": null -} \ No newline at end of file +} diff --git a/release-assistant/test/test_check/mock_data/repo_list_data.txt b/release-assistant/test/test_check/mock_data/repo_list_data.txt index dd6c11e..1c48dd7 100644 --- a/release-assistant/test/test_check/mock_data/repo_list_data.txt +++ b/release-assistant/test/test_check/mock_data/repo_list_data.txt @@ -78,7 +78,7 @@

Index of -/repo.openeuler.org/openEuler-20.03-LTS/update_20210721/

+/repo.openeuler.org/openEuler-20.03-LTS-SP1/update_20210721/ @@ -126,4 +126,4 @@ - \ No newline at end of file + diff --git a/release-assistant/test/test_check/mock_data/single_exist_issues.txt b/release-assistant/test/test_check/mock_data/single_exist_issues.txt index 229a926..9cd6e96 100644 --- a/release-assistant/test/test_check/mock_data/single_exist_issues.txt +++ b/release-assistant/test/test_check/mock_data/single_exist_issues.txt @@ -11,7 +11,7 @@ "parent_id": 0, "depth": 0, "state": "open", - "title": "[openEuler-20.03-LTS] a-test build failed 20210420", + "title": "[openEuler-20.03-LTS-SP1] a-test build failed 20210420", "body": "just for test", "user": { "id": 8079354, @@ -193,4 +193,4 @@ } } -] \ No newline at end of file +] diff --git a/release-assistant/test/test_check/mock_data/test_template_config_aarch64.xml b/release-assistant/test/test_check/mock_data/test_template_config_aarch64.xml index fd80a1a..47146b0 100644 --- a/release-assistant/test/test_check/mock_data/test_template_config_aarch64.xml +++ b/release-assistant/test/test_check/mock_data/test_template_config_aarch64.xml @@ -36,7 +36,7 @@ BRANCH - openEuler-20.03-LTS + openEuler-20.03-LTS-SP1 false @@ -223,4 +223,4 @@ EOF vga - \ No newline at end of file + diff --git a/release-assistant/test/test_check/mock_data/test_template_config_x86.xml b/release-assistant/test/test_check/mock_data/test_template_config_x86.xml index 7b9ee7a..64862af 100644 --- a/release-assistant/test/test_check/mock_data/test_template_config_x86.xml +++ b/release-assistant/test/test_check/mock_data/test_template_config_x86.xml @@ -36,7 +36,7 @@ BRANCH - openEuler-20.03-LTS + openEuler-20.03-LTS-SP1 false @@ -222,4 +222,4 @@ EOF vga - \ No newline at end of file + diff --git a/release-assistant/test/test_check/test_check_cli.py b/release-assistant/test/test_check/test_check_cli.py index 677d3b0..38f65f2 100644 --- a/release-assistant/test/test_check/test_check_cli.py +++ b/release-assistant/test/test_check/test_check_cli.py @@ -40,7 +40,7 @@ class TestCheck(TestMixin): [INFO] successfully to send repo info. """ self.command_params = ["--giteeid=Mary", "--token=example", "--type=status", "--jenkinsuser=mary", - "--jenkinskey=marykey", "--ak=forexample", "--sk=forexample", "I40769"] + "--jenkinskey=marykey", "--ak=forexample", "--sk=forexample", "I40769", "--buildcheck"] resp = self.make_expect_data(200, 'checkpart.txt') self.mock_subprocess_check_output(return_value=b"published-everything-src") mock_bugfix_r = self.make_need_content('mock_bugfix_issue.txt', MOCK_DATA_FILE) @@ -62,7 +62,7 @@ class TestCheck(TestMixin): during the operation status, a failure occurred, and the cause of the error was failed to update status in check part. """ self.command_params = ["--giteeid=Mary", "--token=example", "--type=status", "--jenkinsuser=mary", - "--jenkinskey=marykey", "--ak=forexample", "--sk=forexample", "I40769"] + "--jenkinskey=marykey", "--ak=forexample", "--sk=forexample", "I40769", "--buildcheck"] resp = self.make_expect_data(200, 'checkpart.txt') self.mock_request( side_effect=[resp, resp, RequestException]) @@ -77,7 +77,7 @@ during the operation status, a failure occurred, and the cause of the error was during the operation status, a failure occurred, and the cause of the error was the status of the issue is not all completed, please complete first """ self.command_params = ["--giteeid=Mary", "--token=example", "--type=status", "--jenkinsuser=mary", - "--jenkinskey=marykey", "--ak=forexample", "--sk=forexample", "I40769"] + "--jenkinskey=marykey", "--ak=forexample", "--sk=forexample", "I40769", "--buildcheck"] resp = self.make_expect_data(200, 'checkpart.txt') mock_bugfix_r = self.make_need_content('mock_bugfix_issue.txt', MOCK_DATA_FILE) mock_install_r = self.make_need_content('mock_install_issue.txt', MOCK_DATA_FILE) @@ -98,7 +98,7 @@ during the operation status, a failure occurred, and the cause of the error was [ERROR] failed to send repo info. """ self.command_params = ["--giteeid=Mary", "--token=example", "--type=status", "--jenkinsuser=mary", - "--jenkinskey=marykey", "--ak=forexample", "--sk=forexample", "I40769"] + "--jenkinskey=marykey", "--ak=forexample", "--sk=forexample", "I40769", "--buildcheck"] resp = self.make_expect_data(200, 'checkpart.txt') self.mock_subprocess_check_output(return_value=b"published-everything-src") mock_bugfix_r = self.make_need_content('mock_bugfix_issue.txt', MOCK_DATA_FILE) @@ -121,7 +121,7 @@ during the operation status, a failure occurred, and the cause of the error was [ERROR] failed to send repo info. """ self.command_params = ["--giteeid=Mary", "--token=example", "--type=status", "--jenkinsuser=mary", - "--jenkinskey=marykey", "--ak=forexample", "--sk=forexample", "I40769"] + "--jenkinskey=marykey", "--ak=forexample", "--sk=forexample", "I40769", "--buildcheck"] resp = self.make_expect_data(200, 'checkpart.txt') self.mock_subprocess_check_output(return_value=b"published-everything-src") mock_bugfix_r = self.make_need_content('mock_bugfix_issue.txt', MOCK_DATA_FILE) @@ -144,7 +144,7 @@ during the operation status, a failure occurred, and the cause of the error was [ERROR] failed to send repo info. """ self.command_params = ["--giteeid=Mary", "--token=example", "--type=status", "--jenkinsuser=mary", - "--jenkinskey=marykey", "--ak=forexample", "--sk=forexample", "I40769"] + "--jenkinskey=marykey", "--ak=forexample", "--sk=forexample", "I40769", "--buildcheck"] resp = self.make_expect_data(200, 'checkpart.txt') self.mock_subprocess_check_output(return_value=b"published-everything-src") mock_bugfix_r = self.make_need_content('mock_bugfix_issue.txt', MOCK_DATA_FILE) @@ -168,7 +168,7 @@ during the operation status, a failure occurred, and the cause of the error was [ERROR] failed to send repo info. """ self.command_params = ["--giteeid=Mary", "--token=example", "--type=status", "--jenkinsuser=mary", - "--jenkinskey=marykey", "--ak=forexample", "--sk=forexample", "I40769"] + "--jenkinskey=marykey", "--ak=forexample", "--sk=forexample", "I40769", "--buildcheck"] resp = self.make_expect_data(200, 'checkpart.txt') self.mock_subprocess_check_output(return_value=b"published-everything-src") mock_bugfix_r = self.make_need_content('mock_bugfix_issue.txt', MOCK_DATA_FILE) @@ -189,7 +189,7 @@ during the operation status, a failure occurred, and the cause of the error was [ERROR] failed to send repo info. """ self.command_params = ["--giteeid=Mary", "--token=example", "--type=status", "--jenkinsuser=mary", - "--jenkinskey=marykey", "--ak=forexample", "--sk=forexample", "I40769"] + "--jenkinskey=marykey", "--ak=forexample", "--sk=forexample", "I40769", "--buildcheck"] resp = self.make_expect_data(200, 'checkpart.txt') self.mock_subprocess_check_output(return_value=b"published-everything-src") mock_bugfix_r = self.make_need_content('mock_bugfix_issue.txt', MOCK_DATA_FILE) @@ -212,7 +212,7 @@ during the operation status, a failure occurred, and the cause of the error was [ERROR] failed to send repo info. """ self.command_params = ["--giteeid=Mary", "--token=example", "--type=status", "--jenkinsuser=mary", - "--jenkinskey=marykey", "--ak=forexample", "--sk=forexample", "I40769"] + "--jenkinskey=marykey", "--ak=forexample", "--sk=forexample", "I40769", "--buildcheck"] resp = self.make_expect_data(200, 'checkpart.txt') self.mock_subprocess_check_output(return_value=b"published-everything-src") mock_no_related_issues_r = self.make_need_content('mock_no_related_issues.txt', MOCK_DATA_FILE) @@ -229,7 +229,7 @@ during the operation status, a failure occurred, and the cause of the error was [INFO] successfully operate test in check part. """ self.command_params = ["--giteeid=Mary", "--token=example", "--type=test", "--jenkinsuser=mary", - "--jenkinskey=marykey", "--ak=forexample", "--sk=forexample", "I40769"] + "--jenkinskey=marykey", "--ak=forexample", "--sk=forexample", "I40769", "--buildcheck"] resp = self.make_expect_data(200, 'checkpart.txt') mock_comment_r = self.make_need_content('mock_issue_comment.txt', MOCK_DATA_FILE) mock_cve_bigfix_comment = self.make_need_content('mock_cve_bugfix_comment.txt', MOCK_DATA_FILE) @@ -244,7 +244,7 @@ during the operation status, a failure occurred, and the cause of the error was [ERROR] failed to operate test in check part. """ self.command_params = ["--giteeid=Mary", "--token=example", "--type=test", "--jenkinsuser=mary", - "--jenkinskey=marykey", "--ak=forexample", "--sk=forexample", "I40769"] + "--jenkinskey=marykey", "--ak=forexample", "--sk=forexample", "I40769", "--buildcheck"] resp = self.make_expect_data(200, 'checkpart.txt') self.mock_request(side_effect=[resp, resp, resp, RequestException]) self.assert_result() @@ -257,7 +257,7 @@ during the operation status, a failure occurred, and the cause of the error was [ERROR] failed to operate test in check part. """ self.command_params = ["--giteeid=Mary", "--token=example", "--type=test", "--jenkinsuser=mary", - "--jenkinskey=marykey", "--ak=forexample", "--sk=forexample", "I40769"] + "--jenkinskey=marykey", "--ak=forexample", "--sk=forexample", "I40769", "--buildcheck"] resp = self.make_expect_data(200, 'checkpart.txt') mock_empty_related_personnel_r = self.make_need_content('mock_empty_related_personnel.txt', MOCK_DATA_FILE) self.mock_request(side_effect=[resp, resp, mock_empty_related_personnel_r]) @@ -291,7 +291,7 @@ Parameter validation failed """ self.expect_str = self.read_file_content("requires_success.txt", folder=EXPECT_DATA_FILE, is_json=False) self.command_params = ["--giteeid=Mary", "--token=example", "--type=requires", "--jenkinsuser=mary", - "--jenkinskey=marykey", "--ak=forexample", "--sk=forexample", "I40769"] + "--jenkinskey=marykey", "--ak=forexample", "--sk=forexample", "I40769", "--buildcheck"] self.prepare_jenkins_data() self.prepare_obs_data() resp = self.make_expect_data(200, 'checkpart.txt') @@ -392,7 +392,7 @@ Parameter validation failed self.expect_str = self.read_file_content("check_requires_epol_list_failed.txt", folder=EXPECT_DATA_FILE, is_json=False) self.command_params = ["--giteeid=Mary", "--token=example", "--type=requires", "--jenkinsuser=mary", - "--jenkinskey=marykey", "--ak=forexample", "--sk=forexample", "I40769"] + "--jenkinskey=marykey", "--ak=forexample", "--sk=forexample", "I40769", "--buildcheck"] self.prepare_jenkins_data() self.prepare_obs_data() resp = self.make_expect_data(200, 'check_epol_list.txt', MOCK_DATA_FILE) @@ -446,7 +446,7 @@ already exists the repo url, then update the pkglist in repo. during the operation requires, a failure occurred, and the cause of the error was transfer standard rpm jenkins res: No comment information. The content is: []. """ self.command_params = ["--giteeid=Mary", "--token=example", "--type=requires", "--jenkinsuser=mary", - "--jenkinskey=marykey", "--ak=forexample", "--sk=forexample", "I40769"] + "--jenkinskey=marykey", "--ak=forexample", "--sk=forexample", "I40769", "--buildcheck"] resp = self.make_expect_data(200, 'checkpart.txt') self.prepare_jenkins_data() self.prepare_obs_data() @@ -465,7 +465,7 @@ during the operation requires, a failure occurred, and the cause of the error wa self.expect_str = self.read_file_content("download_pkg_log_failed.txt", folder=EXPECT_DATA_FILE, is_json=False) self.command_params = ["--giteeid=Mary", "--token=example", "--type=requires", "--jenkinsuser=mary", - "--jenkinskey=marykey", "--ak=forexample", "--sk=forexample", "I40769"] + "--jenkinskey=marykey", "--ak=forexample", "--sk=forexample", "I40769", "--buildcheck"] self.prepare_jenkins_data() self.prepare_obs_data(get_objects_status_code=400) resp = self.make_expect_data(200, 'checkpart.txt') @@ -495,7 +495,7 @@ during the operation requires, a failure occurred, and the cause of the error wa self.expect_str = self.read_file_content("write_back_create_install_build_issue_failed.txt", folder=EXPECT_DATA_FILE, is_json=False) self.command_params = ["--giteeid=Mary", "--token=example", "--type=requires", "--jenkinsuser=mary", - "--jenkinskey=marykey", "--ak=forexample", "--sk=forexample", "I40769"] + "--jenkinskey=marykey", "--ak=forexample", "--sk=forexample", "I40769", "--buildcheck"] self.prepare_jenkins_data() self.prepare_obs_data() resp = self.make_expect_data(200, 'checkpart.txt') @@ -522,7 +522,7 @@ during the operation requires, a failure occurred, and the cause of the error wa self.expect_str = self.read_file_content("write_back_operate_release_issue_failed.txt", folder=EXPECT_DATA_FILE, is_json=False) self.command_params = ["--giteeid=Mary", "--token=example", "--type=requires", "--jenkinsuser=mary", - "--jenkinskey=marykey", "--ak=forexample", "--sk=forexample", "I40769"] + "--jenkinskey=marykey", "--ak=forexample", "--sk=forexample", "I40769", "--buildcheck"] resp = self.make_expect_data(200, 'checkpart.txt') self.prepare_jenkins_data() self.prepare_obs_data() diff --git a/release-assistant/test/test_modify/mock_data/add_issue_info.txt b/release-assistant/test/test_modify/mock_data/add_issue_info.txt index 4fbcd67..f66a0a5 100644 --- a/release-assistant/test/test_modify/mock_data/add_issue_info.txt +++ b/release-assistant/test/test_modify/mock_data/add_issue_info.txt @@ -11,7 +11,7 @@ "depth": 0, "state": "closed", "title": "CVE-2020-8020", - "body": "一、漏洞信息\n 漏洞编号:[CVE-2020-8020](https://nvd.nist.gov/vuln/detail/CVE-2020-8020)\n 漏洞归属组件:obs-server\n 漏洞归属的版本:2.10.1\n CVSS V3.0分值:\n BaseScore:6.1 Medium\n Vector:CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N\n 漏洞简述:\n A Improper Neutralization of Input During Web Page Generation vulnerability in open-build-service allows remote attackers to store arbitrary JS code to cause XSS. This issue affects: openSUSE open-build-service versions prior to 7cc32c8e2ff7290698e101d9a80a9dc29a5500fb.\n 漏洞公开时间:\n 漏洞创建时间:2021-03-16 17:25:38\n 漏洞详情参考链接:\n https://nvd.nist.gov/vuln/detail/CVE-2020-8020\n 漏洞分析指导链接:\n https://gitee.com/openeuler/cve-manager/blob/master/doc/md/manual.md\n二、漏洞分析结构反馈\n 影响性分析说明:\n 开放式构建服务中网页生成期间输入的不适当中和漏洞使远程攻击者可以存储任意JS代码以导致XSS。 此问题影响:7cc32c8e2ff7290698e101d9a80a9dc29a5500fb之前的openSUSE开放式构建服务版本。\n openEuler评分:\n 6.1\n Vector:CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N\n 受影响版本排查(受影响/不受影响):\n 1.openEuler-20.03-LTS:受影响\n2.openEuler-20.03-LTS-SP1:受影响\n3.openEuler-20.09:受影响\n\n", + "body": "一、漏洞信息\n 漏洞编号:[CVE-2020-8020](https://nvd.nist.gov/vuln/detail/CVE-2020-8020)\n 漏洞归属组件:obs-server\n 漏洞归属的版本:2.10.1\n CVSS V3.0分值:\n BaseScore:6.1 Medium\n Vector:CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N\n 漏洞简述:\n A Improper Neutralization of Input During Web Page Generation vulnerability in open-build-service allows remote attackers to store arbitrary JS code to cause XSS. This issue affects: openSUSE open-build-service versions prior to 7cc32c8e2ff7290698e101d9a80a9dc29a5500fb.\n 漏洞公开时间:\n 漏洞创建时间:2021-03-16 17:25:38\n 漏洞详情参考链接:\n https://nvd.nist.gov/vuln/detail/CVE-2020-8020\n 漏洞分析指导链接:\n https://gitee.com/openeuler/cve-manager/blob/master/doc/md/manual.md\n二、漏洞分析结构反馈\n 影响性分析说明:\n 开放式构建服务中网页生成期间输入的不适当中和漏洞使远程攻击者可以存储任意JS代码以导致XSS。 此问题影响:7cc32c8e2ff7290698e101d9a80a9dc29a5500fb之前的openSUSE开放式构建服务版本。\n openEuler评分:\n 6.1\n Vector:CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N\n 受影响版本排查(受影响/不受影响):\n 1.openEuler-20.03-LTS-SP1:受影响\n2.openEuler-20.03-LTS-SP3:受影响\n3.openEuler-22.03-LTS:受影响\n\n", "user": { "id": 5329419, "login": "openeuler-ci-bot", @@ -187,4 +187,4 @@ "created_at": "2019-09-24T14:03:20+08:00", "updated_at": "2019-09-24T14:03:20+08:00" } -} \ No newline at end of file +} diff --git a/release-assistant/test/test_modify/mock_data/mock_issue_abi.txt b/release-assistant/test/test_modify/mock_data/mock_issue_abi.txt index c71dd34..54323fc 100644 --- a/release-assistant/test/test_modify/mock_data/mock_issue_abi.txt +++ b/release-assistant/test/test_modify/mock_data/mock_issue_abi.txt @@ -11,7 +11,7 @@ "depth": 0, "state": "closed", "title": "CVE-2020-8020", - "body": "一、漏洞信息\n 漏洞编号:[CVE-2020-8020](https://nvd.nist.gov/vuln/detail/CVE-2020-8020)\n 漏洞归属组件:obs-server\n 漏洞归属的版本:2.10.1\n CVSS V3.0分值:\n Vector:CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N\n 漏洞简述:\n A Improper Neutralization of Input During Web Page Generation vulnerability in open-build-service allows remote attackers to store arbitrary JS code to cause XSS. This issue affects: openSUSE open-build-service versions prior to 7cc32c8e2ff7290698e101d9a80a9dc29a5500fb.\n 漏洞公开时间:\n 漏洞创建时间:2021-03-16 17:25:38\n 漏洞详情参考链接:\n https://nvd.nist.gov/vuln/detail/CVE-2020-8020\n 漏洞分析指导链接:\n https://gitee.com/openeuler/cve-manager/blob/master/doc/md/manual.md\n二、漏洞分析结构反馈\n 影响性分析说明:\n 开放式构建服务中网页生成期间输入的不适当中和漏洞使远程攻击者可以存储任意JS代码以导致XSS。 此问题影响:7cc32c8e2ff7290698e101d9a80a9dc29a5500fb之前的openSUSE开放式构建服务版本。\n Vector:CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N\n 受影响版本排查(受影响/不受影响):\n 1.openEuler-20.03-LTS:受影响\n2.openEuler-20.03-LTS-SP1:受影响\n3.openEuler-20.09:受影响\n\n修复是否涉及abi变化:openEuler-20.03-LTS-SP1 是 \n\n", + "body": "一、漏洞信息\n 漏洞编号:[CVE-2020-8020](https://nvd.nist.gov/vuln/detail/CVE-2020-8020)\n 漏洞归属组件:obs-server\n 漏洞归属的版本:2.10.1\n CVSS V3.0分值:\n Vector:CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N\n 漏洞简述:\n A Improper Neutralization of Input During Web Page Generation vulnerability in open-build-service allows remote attackers to store arbitrary JS code to cause XSS. This issue affects: openSUSE open-build-service versions prior to 7cc32c8e2ff7290698e101d9a80a9dc29a5500fb.\n 漏洞公开时间:\n 漏洞创建时间:2021-03-16 17:25:38\n 漏洞详情参考链接:\n https://nvd.nist.gov/vuln/detail/CVE-2020-8020\n 漏洞分析指导链接:\n https://gitee.com/openeuler/cve-manager/blob/master/doc/md/manual.md\n二、漏洞分析结构反馈\n 影响性分析说明:\n 开放式构建服务中网页生成期间输入的不适当中和漏洞使远程攻击者可以存储任意JS代码以导致XSS。 此问题影响:7cc32c8e2ff7290698e101d9a80a9dc29a5500fb之前的openSUSE开放式构建服务版本。\n Vector:CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N\n 受影响版本排查(受影响/不受影响):\n 1.openEuler-20.03-LTS-SP1:受影响\n2.openEuler-20.03-LTS-SP3:受影响\n3.openEuler-22.03-LTS:受影响\n\n修复是否涉及abi变化:openEuler-22.03-LTS-SP1 是 \n\n", "user": { "id": 5329419, "login": "openeuler-ci-bot", @@ -187,4 +187,4 @@ "created_at": "2019-09-24T14:03:20+08:00", "updated_at": "2019-09-24T14:03:20+08:00" } -} \ No newline at end of file +} diff --git a/release-assistant/test/test_modify/mock_data/mock_issue_basescore.txt b/release-assistant/test/test_modify/mock_data/mock_issue_basescore.txt index 4b60933..45dd4ee 100644 --- a/release-assistant/test/test_modify/mock_data/mock_issue_basescore.txt +++ b/release-assistant/test/test_modify/mock_data/mock_issue_basescore.txt @@ -11,7 +11,7 @@ "depth": 0, "state": "closed", "title": "CVE-2020-8020", - "body": "一、漏洞信息\n 漏洞编号:[CVE-2020-8020](https://nvd.nist.gov/vuln/detail/CVE-2020-8020)\n 漏洞归属组件:obs-server\n 漏洞归属的版本:2.10.1\n CVSS V3.0分值:\n BaseScore:6.1 Medium\n Vector:CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N\n 漏洞简述:\n A Improper Neutralization of Input During Web Page Generation vulnerability in open-build-service allows remote attackers to store arbitrary JS code to cause XSS. This issue affects: openSUSE open-build-service versions prior to 7cc32c8e2ff7290698e101d9a80a9dc29a5500fb.\n 漏洞公开时间:\n 漏洞创建时间:2021-03-16 17:25:38\n 漏洞详情参考链接:\n https://nvd.nist.gov/vuln/detail/CVE-2020-8020\n 漏洞分析指导链接:\n https://gitee.com/openeuler/cve-manager/blob/master/doc/md/manual.md\n二、漏洞分析结构反馈\n 影响性分析说明:\n 开放式构建服务中网页生成期间输入的不适当中和漏洞使远程攻击者可以存储任意JS代码以导致XSS。 此问题影响:7cc32c8e2ff7290698e101d9a80a9dc29a5500fb之前的openSUSE开放式构建服务版本。\n Vector:CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N\n 受影响版本排查(受影响/不受影响):\n 1.openEuler-20.03-LTS:受影响\n2.openEuler-20.03-LTS-SP1:受影响\n3.openEuler-20.09:受影响\n\n", + "body": "一、漏洞信息\n 漏洞编号:[CVE-2020-8020](https://nvd.nist.gov/vuln/detail/CVE-2020-8020)\n 漏洞归属组件:obs-server\n 漏洞归属的版本:2.10.1\n CVSS V3.0分值:\n BaseScore:6.1 Medium\n Vector:CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N\n 漏洞简述:\n A Improper Neutralization of Input During Web Page Generation vulnerability in open-build-service allows remote attackers to store arbitrary JS code to cause XSS. This issue affects: openSUSE open-build-service versions prior to 7cc32c8e2ff7290698e101d9a80a9dc29a5500fb.\n 漏洞公开时间:\n 漏洞创建时间:2021-03-16 17:25:38\n 漏洞详情参考链接:\n https://nvd.nist.gov/vuln/detail/CVE-2020-8020\n 漏洞分析指导链接:\n https://gitee.com/openeuler/cve-manager/blob/master/doc/md/manual.md\n二、漏洞分析结构反馈\n 影响性分析说明:\n 开放式构建服务中网页生成期间输入的不适当中和漏洞使远程攻击者可以存储任意JS代码以导致XSS。 此问题影响:7cc32c8e2ff7290698e101d9a80a9dc29a5500fb之前的openSUSE开放式构建服务版本。\n Vector:CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N\n 受影响版本排查(受影响/不受影响):\n 1.openEuler-20.03-LTS-SP1:受影响\n2.openEuler-20.03-LTS-SP3:受影响\n3.openEuler-22.03-LTS:受影响\n\n", "user": { "id": 5329419, "login": "openeuler-ci-bot", @@ -187,4 +187,4 @@ "created_at": "2019-09-24T14:03:20+08:00", "updated_at": "2019-09-24T14:03:20+08:00" } -} \ No newline at end of file +} diff --git a/release-assistant/test/test_modify/mock_data/mock_issue_no_score.txt b/release-assistant/test/test_modify/mock_data/mock_issue_no_score.txt index f208a0c..b3a06cf 100644 --- a/release-assistant/test/test_modify/mock_data/mock_issue_no_score.txt +++ b/release-assistant/test/test_modify/mock_data/mock_issue_no_score.txt @@ -11,7 +11,7 @@ "depth": 0, "state": "closed", "title": "CVE-2020-8020", - "body": "一、漏洞信息\n 漏洞编号:[CVE-2020-8020](https://nvd.nist.gov/vuln/detail/CVE-2020-8020)\n 漏洞归属组件:obs-server\n 漏洞归属的版本:2.10.1\n CVSS V3.0分值:\n Vector:CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N\n 漏洞简述:\n A Improper Neutralization of Input During Web Page Generation vulnerability in open-build-service allows remote attackers to store arbitrary JS code to cause XSS. This issue affects: openSUSE open-build-service versions prior to 7cc32c8e2ff7290698e101d9a80a9dc29a5500fb.\n 漏洞公开时间:\n 漏洞创建时间:2021-03-16 17:25:38\n 漏洞详情参考链接:\n https://nvd.nist.gov/vuln/detail/CVE-2020-8020\n 漏洞分析指导链接:\n https://gitee.com/openeuler/cve-manager/blob/master/doc/md/manual.md\n二、漏洞分析结构反馈\n 影响性分析说明:\n 开放式构建服务中网页生成期间输入的不适当中和漏洞使远程攻击者可以存储任意JS代码以导致XSS。 此问题影响:7cc32c8e2ff7290698e101d9a80a9dc29a5500fb之前的openSUSE开放式构建服务版本。\n Vector:CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N\n 受影响版本排查(受影响/不受影响):\n 1.openEuler-20.03-LTS:受影响\n2.openEuler-20.03-LTS-SP1:受影响\n3.openEuler-20.09:受影响\n\n", + "body": "一、漏洞信息\n 漏洞编号:[CVE-2020-8020](https://nvd.nist.gov/vuln/detail/CVE-2020-8020)\n 漏洞归属组件:obs-server\n 漏洞归属的版本:2.10.1\n CVSS V3.0分值:\n Vector:CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N\n 漏洞简述:\n A Improper Neutralization of Input During Web Page Generation vulnerability in open-build-service allows remote attackers to store arbitrary JS code to cause XSS. This issue affects: openSUSE open-build-service versions prior to 7cc32c8e2ff7290698e101d9a80a9dc29a5500fb.\n 漏洞公开时间:\n 漏洞创建时间:2021-03-16 17:25:38\n 漏洞详情参考链接:\n https://nvd.nist.gov/vuln/detail/CVE-2020-8020\n 漏洞分析指导链接:\n https://gitee.com/openeuler/cve-manager/blob/master/doc/md/manual.md\n二、漏洞分析结构反馈\n 影响性分析说明:\n 开放式构建服务中网页生成期间输入的不适当中和漏洞使远程攻击者可以存储任意JS代码以导致XSS。 此问题影响:7cc32c8e2ff7290698e101d9a80a9dc29a5500fb之前的openSUSE开放式构建服务版本。\n Vector:CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N\n 受影响版本排查(受影响/不受影响):\n 1.openEuler-20.03-LTS-SP1:受影响\n2.openEuler-20.03-LTS-SP3:受影响\n3.openEuler-22.03-LTS:受影响\n\n", "user": { "id": 5329419, "login": "openeuler-ci-bot", @@ -187,4 +187,4 @@ "created_at": "2019-09-24T14:03:20+08:00", "updated_at": "2019-09-24T14:03:20+08:00" } -} \ No newline at end of file +} diff --git a/release-assistant/test/test_modify/mock_data/mock_remain_issue_1_data.txt b/release-assistant/test/test_modify/mock_data/mock_remain_issue_1_data.txt index c2525ad..b39a0b6 100644 --- a/release-assistant/test/test_modify/mock_data/mock_remain_issue_1_data.txt +++ b/release-assistant/test/test_modify/mock_data/mock_remain_issue_1_data.txt @@ -11,7 +11,7 @@ "depth": 0, "state": "closed", "title": "CVE-2020-8020", - "body": "一、漏洞信息\n 漏洞编号:[CVE-2020-8020](https://nvd.nist.gov/vuln/detail/CVE-2020-8020)\n 漏洞归属组件:obs-server\n 漏洞归属的版本:2.10.1\n CVSS V3.0分值:\n BaseScore:6.1 Medium\n Vector:CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N\n 漏洞简述:\n A Improper Neutralization of Input During Web Page Generation vulnerability in open-build-service allows remote attackers to store arbitrary JS code to cause XSS. This issue affects: openSUSE open-build-service versions prior to 7cc32c8e2ff7290698e101d9a80a9dc29a5500fb.\n 漏洞公开时间:\n 漏洞创建时间:2021-03-16 17:25:38\n 漏洞详情参考链接:\n https://nvd.nist.gov/vuln/detail/CVE-2020-8020\n 漏洞分析指导链接:\n https://gitee.com/openeuler/cve-manager/blob/master/doc/md/manual.md\n二、漏洞分析结构反馈\n 影响性分析说明:\n 开放式构建服务中网页生成期间输入的不适当中和漏洞使远程攻击者可以存储任意JS代码以导致XSS。 此问题影响:7cc32c8e2ff7290698e101d9a80a9dc29a5500fb之前的openSUSE开放式构建服务版本。\n openEuler评分:\n 6.1\n Vector:CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N\n 受影响版本排查(受影响/不受影响):\n 1.openEuler-20.03-LTS:受影响\n2.openEuler-20.03-LTS-SP1:受影响\n3.openEuler-20.09:受影响\n\n", + "body": "一、漏洞信息\n 漏洞编号:[CVE-2020-8020](https://nvd.nist.gov/vuln/detail/CVE-2020-8020)\n 漏洞归属组件:obs-server\n 漏洞归属的版本:2.10.1\n CVSS V3.0分值:\n BaseScore:6.1 Medium\n Vector:CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N\n 漏洞简述:\n A Improper Neutralization of Input During Web Page Generation vulnerability in open-build-service allows remote attackers to store arbitrary JS code to cause XSS. This issue affects: openSUSE open-build-service versions prior to 7cc32c8e2ff7290698e101d9a80a9dc29a5500fb.\n 漏洞公开时间:\n 漏洞创建时间:2021-03-16 17:25:38\n 漏洞详情参考链接:\n https://nvd.nist.gov/vuln/detail/CVE-2020-8020\n 漏洞分析指导链接:\n https://gitee.com/openeuler/cve-manager/blob/master/doc/md/manual.md\n二、漏洞分析结构反馈\n 影响性分析说明:\n 开放式构建服务中网页生成期间输入的不适当中和漏洞使远程攻击者可以存储任意JS代码以导致XSS。 此问题影响:7cc32c8e2ff7290698e101d9a80a9dc29a5500fb之前的openSUSE开放式构建服务版本。\n openEuler评分:\n 6.1\n Vector:CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N\n 受影响版本排查(受影响/不受影响):\n 1.openEuler-20.03-LTS-SP1:受影响\n2.openEuler-20.03-LTS-SP3:受影响\n3.openEuler-22.03-LTS:受影响\n\n", "user": { "id": 5329419, "login": "openeuler-ci-bot", @@ -187,4 +187,4 @@ "created_at": "2019-09-24T14:03:20+08:00", "updated_at": "2019-09-24T14:03:20+08:00" } -} \ No newline at end of file +} diff --git a/release-assistant/test/test_modify/mock_data/mock_remain_issue_2_data.txt b/release-assistant/test/test_modify/mock_data/mock_remain_issue_2_data.txt index c68282c..61113d1 100644 --- a/release-assistant/test/test_modify/mock_data/mock_remain_issue_2_data.txt +++ b/release-assistant/test/test_modify/mock_data/mock_remain_issue_2_data.txt @@ -11,7 +11,7 @@ "depth": 0, "state": "closed", "title": "CVE-2020-8020", - "body": "一、漏洞信息\n 漏洞编号:[CVE-2020-8020](https://nvd.nist.gov/vuln/detail/CVE-2020-8020)\n 漏洞归属组件:obs-server\n 漏洞归属的版本:2.10.1\n CVSS V3.0分值:\n BaseScore:6.1 Medium\n Vector:CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N\n 漏洞简述:\n A Improper Neutralization of Input During Web Page Generation vulnerability in open-build-service allows remote attackers to store arbitrary JS code to cause XSS. This issue affects: openSUSE open-build-service versions prior to 7cc32c8e2ff7290698e101d9a80a9dc29a5500fb.\n 漏洞公开时间:\n 漏洞创建时间:2021-03-16 17:25:38\n 漏洞详情参考链接:\n https://nvd.nist.gov/vuln/detail/CVE-2020-8020\n 漏洞分析指导链接:\n https://gitee.com/openeuler/cve-manager/blob/master/doc/md/manual.md\n二、漏洞分析结构反馈\n 影响性分析说明:\n 开放式构建服务中网页生成期间输入的不适当中和漏洞使远程攻击者可以存储任意JS代码以导致XSS。 此问题影响:7cc32c8e2ff7290698e101d9a80a9dc29a5500fb之前的openSUSE开放式构建服务版本。\n openEuler评分:\n 6.1\n Vector:CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N\n 受影响版本排查(受影响/不受影响):\n 1.openEuler-20.03-LTS:受影响\n2.openEuler-20.03-LTS-SP1:受影响\n3.openEuler-20.09:受影响\n\n", + "body": "一、漏洞信息\n 漏洞编号:[CVE-2020-8020](https://nvd.nist.gov/vuln/detail/CVE-2020-8020)\n 漏洞归属组件:obs-server\n 漏洞归属的版本:2.10.1\n CVSS V3.0分值:\n BaseScore:6.1 Medium\n Vector:CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N\n 漏洞简述:\n A Improper Neutralization of Input During Web Page Generation vulnerability in open-build-service allows remote attackers to store arbitrary JS code to cause XSS. This issue affects: openSUSE open-build-service versions prior to 7cc32c8e2ff7290698e101d9a80a9dc29a5500fb.\n 漏洞公开时间:\n 漏洞创建时间:2021-03-16 17:25:38\n 漏洞详情参考链接:\n https://nvd.nist.gov/vuln/detail/CVE-2020-8020\n 漏洞分析指导链接:\n https://gitee.com/openeuler/cve-manager/blob/master/doc/md/manual.md\n二、漏洞分析结构反馈\n 影响性分析说明:\n 开放式构建服务中网页生成期间输入的不适当中和漏洞使远程攻击者可以存储任意JS代码以导致XSS。 此问题影响:7cc32c8e2ff7290698e101d9a80a9dc29a5500fb之前的openSUSE开放式构建服务版本。\n openEuler评分:\n 6.1\n Vector:CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N\n 受影响版本排查(受影响/不受影响):\n 1.openEuler-20.03-LTS-SP1:受影响\n2.openEuler-20.03-LTS-SP3:受影响\n3.openEuler-22.03-LTS:受影响\n\n", "user": { "id": 5329419, "login": "openeuler-ci-bot", @@ -187,4 +187,4 @@ "created_at": "2019-09-24T14:03:20+08:00", "updated_at": "2019-09-24T14:03:20+08:00" } -} \ No newline at end of file +} -- Gitee From f2cf3c63e4b3bf4c9fc40dad960b768752e8007e Mon Sep 17 00:00:00 2001 From: e Date: Fri, 23 Dec 2022 15:23:04 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E6=93=8D=E4=BD=9C=20repo,=E5=8F=91?= =?UTF-8?q?=E9=80=81=E6=95=B0=E6=8D=AE=E7=BB=99=E6=B5=8B=E8=AF=95=E5=B9=B3?= =?UTF-8?q?=E5=8F=B0,cvrf=E5=92=8Cupdate=20info=20=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../javcra/application/majun/__init__.py | 68 +++ .../javcra/application/majun/majunoperate.py | 405 ++++++++++++++++++ release-assistant/javcra/common/constant.py | 21 +- 3 files changed, 491 insertions(+), 3 deletions(-) create mode 100644 release-assistant/javcra/application/majun/__init__.py create mode 100644 release-assistant/javcra/application/majun/majunoperate.py diff --git a/release-assistant/javcra/application/majun/__init__.py b/release-assistant/javcra/application/majun/__init__.py new file mode 100644 index 0000000..d742c47 --- /dev/null +++ b/release-assistant/javcra/application/majun/__init__.py @@ -0,0 +1,68 @@ +#!/usr/bin/python3 +# ****************************************************************************** +# Copyright (c) Huawei Technologies Co., Ltd. 2020-2022. All rights reserved. +# licensed under the Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan PSL v2. +# You may obtain a copy of Mulan PSL v2 at: +# http://license.coscl.org.cn/MulanPSL2 +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR +# PURPOSE. +# See the Mulan PSL v2 for more details. +# ******************************************************************************/ +import os +from functools import wraps + +from javcra.libs.log import logger + + +def get_product_version(task_title): + """ + + """ + return "", "", "" + + +def send_content_majun(content, majun_id, multip_start=False): + """ + + Args: + content: + majun_id: + multip_start: + + Returns: + + """ + return "" + + +def catch_majun_error(func): + """ + Exception capture decorator + """ + + @wraps(func) + def inner(*args, **kwargs): + """ + capture decorator + """ + _, params = args + try: + if not os.getenv("majun_access_token"): + raise ValueError( + "Failed to obtain the majun access token value. Please check the Settings of " + "jenkins engineering environment variables" + ) + return func(*args, **kwargs) + except ( + ValueError, + AttributeError, + KeyError, + TypeError, + FileNotFoundError, + ) as err: + logger.error(f"jenkins error {err}") + send_content_majun(False, params.id) + + return inner diff --git a/release-assistant/javcra/application/majun/majunoperate.py b/release-assistant/javcra/application/majun/majunoperate.py new file mode 100644 index 0000000..f4b2f02 --- /dev/null +++ b/release-assistant/javcra/application/majun/majunoperate.py @@ -0,0 +1,405 @@ +#!/usr/bin/python3 +# ****************************************************************************** +# Copyright (c) Huawei Technologies Co., Ltd. 2020-2022. All rights reserved. +# licensed under the Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan PSL v2. +# You may obtain a copy of Mulan PSL v2 at: +# http://license.coscl.org.cn/MulanPSL2 +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR +# PURPOSE. +# See the Mulan PSL v2 for more details. +# ******************************************************************************/ +import copy +import json +import requests +from concurrent.futures import ThreadPoolExecutor, as_completed +from javcra.api.gitee_api import Issue +from javcra.common.constant import ( + CVE_UPDATE_INFO_JOB_NAME, + CVRF_JOB_NAME, + EPOL_DICT, + MAX_PARAL_NUM, + MULTI_VERSION_BRANCHS, + OBS_PROJECT_MULTI_VERSION_MAP, + REPO_BASE_URL, + TEST_MILESTONE_URL, +) +from javcra.application.majun import ( + catch_majun_error, + get_product_version, + send_content_majun, +) +from javcra.api.jenkins_api import JenkinsJob +from javcra.common import constant +from javcra.libs.log import logger + + +class MajunOperate: + """ + Operation jenkins sends data to majun + """ + + def __init__(self) -> None: + self.task_title = None + self.pkglist = None + self.jenkins_server_obj = None + self.headers = { + "Content-Type": "application/json; charset=utf8", + "User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:30.0) Gecko/20100101 Firefox/30.0", + } + + def get_repo(self, branch_name, release_date, pkglist): + """ + get repo according to branch 、date and epol + Args: + branch_name: branch name + release_date: Release date + pkglist: package names + + Returns: + repos: Addresses of all generated repo + standard_list: standard package names + epol_list: epol package names + """ + standard_list, epol_list = Issue.get_standard_epol_list(branch_name, pkglist) + base_url = REPO_BASE_URL + branch_name + repos = [{"repo_type": "standard", "url": f"{base_url}/update_{release_date}/"}] + if epol_list: + repo_dict = dict() + repo_dict["repo_type"] = "epol" + if any(mul_branch in branch_name for mul_branch in MULTI_VERSION_BRANCHS): + repo_dict["url"] = f"{base_url}/EPOL/update_{release_date}/main/" + else: + repo_dict["url"] = f"{base_url}/EPOL/update_{release_date}/" + repos.append(repo_dict) + return repos, standard_list, epol_list + + def send_data_test_platform(self, update_data, majun_id): + """ + Send data to the test platform and get milestones + Args: + update_data: Data sent to the test platform + majun_id: majub id + + Returns: + The result of sending the data to majun + """ + + try: + resp = requests.post( + TEST_MILESTONE_URL, data=json.dumps(update_data), headers=self.headers + ) + except requests.RequestException as error: + raise ValueError(f"Request test failed, {error}") + try: + res_text = json.loads(resp.text) + except json.JSONDecodeError as error: + raise ValueError(f"JSONDecodeError,because {error}") + if not resp or resp.status_code != 200 or res_text.get("error_code") != "2000": + raise ValueError(f"Request test failed,{resp.status_code} and {resp.text}") + else: + logger.info("Successful milestone acquisition") + return send_content_majun( + res_text.get("data", {}).get("milestone_name"), majun_id + ) + + @catch_majun_error + def send_repo_info(self, params): + """ + to send repo info + Args: + params: Command line argument + Returns: + True or False + """ + majun_id, self.pkglist, self.task_title = ( + params.id, + params.pkglist, + params.task_title, + ) + branch_name, release_date, multi_content = get_product_version(self.task_title) + product_version = branch_name.split("-", 1) + update_data = { + "product": product_version[0], + "version": product_version[1], + "pkgs": self.pkglist, + } + if not multi_content: + # The normal version sends data + repo_list, _, _ = self.get_repo(branch_name, release_date, self.pkglist) + # branch demo: openEuler-20.03-LTS-SP1 + for repo_info in repo_list: + if repo_info.get("repo_type") == "standard": + update_data["base_update_url"] = repo_info.get("url") + else: + update_data["epol_update_url"] = repo_info.get("url") + else: + # Multiple versions send data + multi_contents = multi_content.rsplit(":", 2) + folder_name = f"{multi_contents[-1]}/{multi_contents[-2]}" + + update_data[ + "base_update_url" + ] = f"{REPO_BASE_URL}{branch_name}/update_{release_date}/" + update_data[ + "epol_update_url" + ] = f"{REPO_BASE_URL}{branch_name}/EPOL/update_{release_date}/multi_version/{folder_name}/" + return self.send_data_test_platform(update_data, majun_id) + + @staticmethod + def jenkins_server( + params, + paral_num=MAX_PARAL_NUM, + release_date="", + branch_name="", + ): + """ + Description: to get the jenkins server + Args: + params: Command line parameters + paral_num: paral num of jenkins job + branch_name: branch name of release issue + release_date: date of release + + Returns: + jenkins server object + """ + jenkins_server = JenkinsJob( + constant.JENKINS_BASE_URL, + params.jenkinsuser, + params.jenkinskey, + paral_num, + branch_name, + release_date, + ) + return jenkins_server + + def transfer_pkg_rpm( + self, obs_project, pkg_family, obs_action, release_date, pkgs=None + ): + """ + transfer the rpm package to the server, and comment on the Jenkins + job result on the release issue + """ + obs_job_params = { + "ScanOSSAPIURL": constant.JENKINS_API_URL, + "ScanOSSResultRepo": constant.JENKINS_SERVER_REPO, + "action": obs_action, + "obs_project": obs_project, + "update_dir": "update_" + release_date, + "package_family": pkg_family, + } + if pkgs: + obs_job_params.update({"pkgnamelist": ",".join(pkgs)}) + jenkins_obs_res = self.jenkins_server_obj.get_specific_job_comment( + obs_job_params, constant.OBS_RELEASE_JOB + ) + return jenkins_obs_res + + @staticmethod + def judge_result(transfer_res): + """ + Determine jenkins running results + Args: + transfer_res: jenkins results + + Returns: + Return true on success and false on failure + """ + return ( + True + if transfer_res and transfer_res[0].get("status") == "SUCCESS" + else False + ) + + def _normal_repo(self, branch_name, release_date, obs_project, params): + """ + Daily operation repo + Args: + branch_name: branch name + release_date: release data + obs_project: obs project name + params: Command line argument + + Returns: + Send data to majun result + """ + repos, standard_packages, epol_packages = self.get_repo( + branch_name, release_date, params.pkglist + ) + stand_transfer_res = self.transfer_pkg_rpm( + obs_project, "standard", params.action, release_date, pkgs=standard_packages + ) + if not self.judge_result(stand_transfer_res): + return send_content_majun(False, params.id) + if epol_packages: + pkg_family = EPOL_DICT.get(branch_name) + if not pkg_family: + raise ValueError( + f"failed to get epol name of jenkins job for {branch_name}" + ) + obs_project = obs_project + ":" + "Epol" + epol_transfer_res = self.transfer_pkg_rpm( + obs_project, pkg_family, epol_packages, params.action, release_date + ) + if not self.judge_result(epol_transfer_res): + return send_content_majun(False, params.id) + if params.action == "create": + data = {repo.get("repo_type"): repo.get("url") for repo in repos} + elif params.action == "del_pkg_rpm": + data = ",".join(params.pkglist) + else: + data = True + return send_content_majun(data, params.id) + + def _multi_repo(self, branch_name, release_date, obs_project, params, folder_name): + """ + Multi-version operation repo + Args: + branch_name: branch name + release_date: release data + obs_project: obs project name + params: Command line argument + folder_name: folder name + + Returns: + Send data to majun + """ + if obs_project not in OBS_PROJECT_MULTI_VERSION_MAP.keys(): + raise ValueError( + "If the package has multiple versions, package_family must have a value" + ) + package_family = "EPOL-multi_version" + _transfer_res = self.transfer_pkg_rpm( + obs_project, + package_family, + params.action, + release_date, + pkgs=params.pkglist, + ) + if not self.judge_result(_transfer_res): + return send_content_majun(False, params.id) + if params.action == "create": + data = { + "epol": f"{REPO_BASE_URL}{branch_name}/EPOL/update_{release_date}/multi_version/{folder_name}" + } + elif params.action == "del_pkg_rpm": + data = ",".join(params.pkglist) + else: + data = True + return send_content_majun(data, params.id) + + @catch_majun_error + def operate_repo(self, params): + """ + Manipulate the main entry to the repo source + Args: + params: Command line argument + + Returns: + result to majun + """ + self.task_title = params.task_title + branch_name, release_date, multi_content = get_product_version(self.task_title) + if multi_content: + obs_project = f"{branch_name.replace('-', ':')}:{multi_content}" + multi_contents = multi_content.rsplit(":", 2) + folder_name = f"{multi_contents[-1]}/{multi_contents[-2]}" + else: + obs_project = branch_name.replace("-", ":") + folder_name = None + # get jenkins_server object + self.jenkins_server_obj = self.jenkins_server( + params, MAX_PARAL_NUM, branch_name, release_date + ) + if params.action in ["create", "del_pkg_rpm", "update"]: + # The create del_pkg_rpm update action is mandatory according to pkglist + if not multi_content: + # Daily version operation + return self._normal_repo(branch_name, release_date, obs_project, params) + else: + # Multiversion operation + return self._multi_repo( + branch_name, release_date, obs_project, params, folder_name + ) + else: + # del_update_dir + stand_transfer_res = self.transfer_pkg_rpm( + obs_project, params.package_family, params.action, release_date + ) + return send_content_majun(self.judge_result(stand_transfer_res), params.id) + + def _single_sync(self, params, jenkins_params): + """ + cvrf or update info jenkins job + Args: + params: incoming params + jenkins_params: jenkins params + + Returns: + send data to majun + """ + if params.choice == "cvrf": + jenkins_params.update({"filename": params.cvrffilename}) + else: + jenkins_params.update({"filename": params.updatefilename}) + jenkins_job = ( + CVRF_JOB_NAME if params.choice == "cvrf" else CVE_UPDATE_INFO_JOB_NAME + ) + jenkins_obs_res = self.jenkins_server_obj.get_specific_job_comment( + jenkins_params, jenkins_job + ) + return send_content_majun(self.judge_result(jenkins_obs_res), params.id) + + def _all_sync(self, params, jenkins_params): + """ + Call both the cvrf and update info tasks + Args: + params: Incoming parameter + jenkins_params: jenkins task parameter + + Returns: + Send data to majun + """ + new_params = copy.deepcopy(jenkins_params) + jenkins_params.update({"filename": params.cvrffilename}) + new_params.update({"filename": params.updatefilename}) + with ThreadPoolExecutor(max_workers=2) as pool: + cvrf_future = pool.submit( + self.jenkins_server_obj.get_specific_job_comment, + jenkins_params, + CVRF_JOB_NAME, + ) + updateinfo_future = pool.submit( + self.jenkins_server_obj.get_specific_job_comment, + new_params, + CVE_UPDATE_INFO_JOB_NAME, + ) + jenkins_result = all( + [ + self.judge_result(future.result()) + for future in as_completed([cvrf_future, updateinfo_future]) + ] + ) + # Send data to majun + return send_content_majun(jenkins_result, params.id) + + @catch_majun_error + def synchronous_info(self, params): + """ + Call cvrf synchronization and updateinfo to synchronize the jenkins project + Args: + params: Incoming parameter + + Returns: + jenkins runs the result back to majun + """ + self.jenkins_server_obj = self.jenkins_server(params) + jenkins_params = dict( + server=params.server, bucketname=params.bucketname, ipaddr=params.ipaddr + ) + sync_func_map = {"cvrf": "single", "updateinfo": "single", "all": "all"} + return getattr(self, "_{}_sync".format(sync_func_map.get(params.choice)))( + params, jenkins_params + ) diff --git a/release-assistant/javcra/common/constant.py b/release-assistant/javcra/common/constant.py index 5592400..bd94dc0 100644 --- a/release-assistant/javcra/common/constant.py +++ b/release-assistant/javcra/common/constant.py @@ -164,14 +164,29 @@ LABEL_DICT = {"start": "check-pkg", "requires": "check-requires", "release": "re MULTI_VERSION_BRANCHS = ["sp2", "sp3", "SP2", "SP3"] -CHECK_PART_LIST = ["status", "requires", "test", "cve_bugfix", "versions"] - VERSION_TABLE_HEADER = ["package_name", "gitee-sp1", "obs-sp1", "gitee-sp3", "obs-sp3", "gitee-sp2203", "obs-sp2203"] CHECK_RESULT_CSV_PATH = "update_packages2/src/check_result.csv" -#staff +# staff VERSION_MANAGER = "@gitee-cmd @zhangtao2020" DEVELOPER = "@gitee-cmd @zhangtao2020 @caodongxia @yaoxin" SECURITY_COMMITTEE = "@yanxiaobing2020 @gitee-cmd @zhangtao2020" TESTER = "@gitee-cmd @zhangtao2020 @disnight" + +CHECK_PART_LIST = ["status", "requires", "test", "cve_bugfix"] + +# jenkins cvrf name +CVRF_JOB_NAME = "obs/update_cve_xml_file_automatic" + +# jenkins update info name +CVE_UPDATE_INFO_JOB_NAME = "function-item/update_repodata_by_updateinfo_automatic" + +# Multi-version mapping +OBS_PROJECT_MULTI_VERSION_MAP = { + "openEuler:22.03:LTS:Epol:Multi-Version:OpenStack:Train": "Multi-Version_OpenStack-Train_openEuler-22.03-LTS", + "openEuler:22.03:LTS:Epol:Multi-Version:OpenStack:Wallaby": "Multi-Version_OpenStack-Wallaby_openEuler-22.03-LTS", + "openEuler:22.03:LTS:Epol:Multi-Version:obs-server:2.10.11": "Multi-Version_obs-server-2.10.11_openEuler-22.03-LTS", +} +# Test milestone routing +TEST_MILESTONE_URL = "http://radiatest.openeuler.org/api/v1/openeuler/update-release/validate" -- Gitee From 736198411855353c3f494b14032a45d1bc62e960 Mon Sep 17 00:00:00 2001 From: e Date: Fri, 23 Dec 2022 16:21:20 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E6=93=8D=E4=BD=9C=20repo,=E5=8F=91?= =?UTF-8?q?=E9=80=81=E6=95=B0=E6=8D=AE=E7=BB=99=E6=B5=8B=E8=AF=95=E5=B9=B3?= =?UTF-8?q?=E5=8F=B0,cvrf=E5=92=8Cupdate=20info=20=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../javcra/application/majun/majunoperate.py | 204 +++++++++--------- 1 file changed, 100 insertions(+), 104 deletions(-) diff --git a/release-assistant/javcra/application/majun/majunoperate.py b/release-assistant/javcra/application/majun/majunoperate.py index f4b2f02..e54b185 100644 --- a/release-assistant/javcra/application/majun/majunoperate.py +++ b/release-assistant/javcra/application/majun/majunoperate.py @@ -12,8 +12,8 @@ # ******************************************************************************/ import copy import json -import requests from concurrent.futures import ThreadPoolExecutor, as_completed +import requests from javcra.api.gitee_api import Issue from javcra.common.constant import ( CVE_UPDATE_INFO_JOB_NAME, @@ -49,7 +49,8 @@ class MajunOperate: "User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:30.0) Gecko/20100101 Firefox/30.0", } - def get_repo(self, branch_name, release_date, pkglist): + @staticmethod + def get_repo(branch_name, release_date, pkglist): """ get repo according to branch 、date and epol Args: @@ -75,6 +76,18 @@ class MajunOperate: repos.append(repo_dict) return repos, standard_list, epol_list + @staticmethod + def judge_result(transfer_res): + """ + Determine jenkins running results + Args: + transfer_res: jenkins results + + Returns: + Return true on success and false on failure + """ + return True if transfer_res and transfer_res[0].get("status") == "SUCCESS" else False + def send_data_test_platform(self, update_data, majun_id): """ Send data to the test platform and get milestones @@ -91,11 +104,11 @@ class MajunOperate: TEST_MILESTONE_URL, data=json.dumps(update_data), headers=self.headers ) except requests.RequestException as error: - raise ValueError(f"Request test failed, {error}") + raise ValueError(f"Request test failed, {error}") from error try: res_text = json.loads(resp.text) except json.JSONDecodeError as error: - raise ValueError(f"JSONDecodeError,because {error}") + raise ValueError(f"JSONDecodeError,because {error}") from error if not resp or resp.status_code != 200 or res_text.get("error_code") != "2000": raise ValueError(f"Request test failed,{resp.status_code} and {resp.text}") else: @@ -149,10 +162,10 @@ class MajunOperate: @staticmethod def jenkins_server( - params, - paral_num=MAX_PARAL_NUM, - release_date="", - branch_name="", + params, + paral_num=MAX_PARAL_NUM, + release_date="", + branch_name="", ): """ Description: to get the jenkins server @@ -175,13 +188,12 @@ class MajunOperate: ) return jenkins_server - def transfer_pkg_rpm( - self, obs_project, pkg_family, obs_action, release_date, pkgs=None - ): + def transfer_pkg_rpm(self, *args, pkgs=None): """ transfer the rpm package to the server, and comment on the Jenkins job result on the release issue """ + obs_project, pkg_family, obs_action, release_date = args obs_job_params = { "ScanOSSAPIURL": constant.JENKINS_API_URL, "ScanOSSResultRepo": constant.JENKINS_SERVER_REPO, @@ -197,99 +209,6 @@ class MajunOperate: ) return jenkins_obs_res - @staticmethod - def judge_result(transfer_res): - """ - Determine jenkins running results - Args: - transfer_res: jenkins results - - Returns: - Return true on success and false on failure - """ - return ( - True - if transfer_res and transfer_res[0].get("status") == "SUCCESS" - else False - ) - - def _normal_repo(self, branch_name, release_date, obs_project, params): - """ - Daily operation repo - Args: - branch_name: branch name - release_date: release data - obs_project: obs project name - params: Command line argument - - Returns: - Send data to majun result - """ - repos, standard_packages, epol_packages = self.get_repo( - branch_name, release_date, params.pkglist - ) - stand_transfer_res = self.transfer_pkg_rpm( - obs_project, "standard", params.action, release_date, pkgs=standard_packages - ) - if not self.judge_result(stand_transfer_res): - return send_content_majun(False, params.id) - if epol_packages: - pkg_family = EPOL_DICT.get(branch_name) - if not pkg_family: - raise ValueError( - f"failed to get epol name of jenkins job for {branch_name}" - ) - obs_project = obs_project + ":" + "Epol" - epol_transfer_res = self.transfer_pkg_rpm( - obs_project, pkg_family, epol_packages, params.action, release_date - ) - if not self.judge_result(epol_transfer_res): - return send_content_majun(False, params.id) - if params.action == "create": - data = {repo.get("repo_type"): repo.get("url") for repo in repos} - elif params.action == "del_pkg_rpm": - data = ",".join(params.pkglist) - else: - data = True - return send_content_majun(data, params.id) - - def _multi_repo(self, branch_name, release_date, obs_project, params, folder_name): - """ - Multi-version operation repo - Args: - branch_name: branch name - release_date: release data - obs_project: obs project name - params: Command line argument - folder_name: folder name - - Returns: - Send data to majun - """ - if obs_project not in OBS_PROJECT_MULTI_VERSION_MAP.keys(): - raise ValueError( - "If the package has multiple versions, package_family must have a value" - ) - package_family = "EPOL-multi_version" - _transfer_res = self.transfer_pkg_rpm( - obs_project, - package_family, - params.action, - release_date, - pkgs=params.pkglist, - ) - if not self.judge_result(_transfer_res): - return send_content_majun(False, params.id) - if params.action == "create": - data = { - "epol": f"{REPO_BASE_URL}{branch_name}/EPOL/update_{release_date}/multi_version/{folder_name}" - } - elif params.action == "del_pkg_rpm": - data = ",".join(params.pkglist) - else: - data = True - return send_content_majun(data, params.id) - @catch_majun_error def operate_repo(self, params): """ @@ -403,3 +322,80 @@ class MajunOperate: return getattr(self, "_{}_sync".format(sync_func_map.get(params.choice)))( params, jenkins_params ) + + def _normal_repo(self, branch_name, release_date, obs_project, params): + """ + Daily operation repo + Args: + branch_name: branch name + release_date: release data + obs_project: obs project name + params: Command line argument + + Returns: + Send data to majun result + """ + repos, standard_packages, epol_packages = self.get_repo( + branch_name, release_date, params.pkglist + ) + stand_transfer_res = self.transfer_pkg_rpm( + obs_project, "standard", params.action, release_date, pkgs=standard_packages + ) + if not self.judge_result(stand_transfer_res): + return send_content_majun(False, params.id) + if epol_packages: + pkg_family = EPOL_DICT.get(branch_name) + if not pkg_family: + raise ValueError( + f"failed to get epol name of jenkins job for {branch_name}" + ) + obs_project = obs_project + ":" + "Epol" + epol_transfer_res = self.transfer_pkg_rpm( + obs_project, pkg_family, epol_packages, params.action, release_date + ) + if not self.judge_result(epol_transfer_res): + return send_content_majun(False, params.id) + if params.action == "create": + data = {repo.get("repo_type"): repo.get("url") for repo in repos} + elif params.action == "del_pkg_rpm": + data = ",".join(params.pkglist) + else: + data = True + return send_content_majun(data, params.id) + + def _multi_repo(self, branch_name, release_date, obs_project, params, folder_name): + """ + Multi-version operation repo + Args: + branch_name: branch name + release_date: release data + obs_project: obs project name + params: Command line argument + folder_name: folder name + + Returns: + Send data to majun + """ + if obs_project not in OBS_PROJECT_MULTI_VERSION_MAP.keys(): + raise ValueError( + "If the package has multiple versions, package_family must have a value" + ) + package_family = "EPOL-multi_version" + _transfer_res = self.transfer_pkg_rpm( + obs_project, + package_family, + params.action, + release_date, + pkgs=params.pkglist, + ) + if not self.judge_result(_transfer_res): + return send_content_majun(False, params.id) + if params.action == "create": + data = { + "epol": f"{REPO_BASE_URL}{branch_name}/EPOL/update_{release_date}/multi_version/{folder_name}" + } + elif params.action == "del_pkg_rpm": + data = ",".join(params.pkglist) + else: + data = True + return send_content_majun(data, params.id) -- Gitee From 1c49936a17791e82fec1a231f4c8f515b4aa489f Mon Sep 17 00:00:00 2001 From: e Date: Fri, 23 Dec 2022 16:40:35 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E6=93=8D=E4=BD=9C=20repo,=E5=8F=91?= =?UTF-8?q?=E9=80=81=E6=95=B0=E6=8D=AE=E7=BB=99=E6=B5=8B=E8=AF=95=E5=B9=B3?= =?UTF-8?q?=E5=8F=B0,cvrf=E5=92=8Cupdate=20info=20=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../javcra/application/majun/__init__.py | 2 +- .../javcra/application/majun/majunoperate.py | 97 ++++++++++--------- 2 files changed, 50 insertions(+), 49 deletions(-) diff --git a/release-assistant/javcra/application/majun/__init__.py b/release-assistant/javcra/application/majun/__init__.py index d742c47..cb2d9c8 100644 --- a/release-assistant/javcra/application/majun/__init__.py +++ b/release-assistant/javcra/application/majun/__init__.py @@ -63,6 +63,6 @@ def catch_majun_error(func): FileNotFoundError, ) as err: logger.error(f"jenkins error {err}") - send_content_majun(False, params.id) + return send_content_majun(False, params.id) return inner diff --git a/release-assistant/javcra/application/majun/majunoperate.py b/release-assistant/javcra/application/majun/majunoperate.py index e54b185..c577287 100644 --- a/release-assistant/javcra/application/majun/majunoperate.py +++ b/release-assistant/javcra/application/majun/majunoperate.py @@ -88,6 +88,34 @@ class MajunOperate: """ return True if transfer_res and transfer_res[0].get("status") == "SUCCESS" else False + @staticmethod + def jenkins_server( + params, + paral_num=MAX_PARAL_NUM, + release_date="", + branch_name="", + ): + """ + Description: to get the jenkins server + Args: + params: Command line parameters + paral_num: paral num of jenkins job + branch_name: branch name of release issue + release_date: date of release + + Returns: + jenkins server object + """ + jenkins_server = JenkinsJob( + constant.JENKINS_BASE_URL, + params.jenkinsuser, + params.jenkinskey, + paral_num, + branch_name, + release_date, + ) + return jenkins_server + def send_data_test_platform(self, update_data, majun_id): """ Send data to the test platform and get milestones @@ -160,34 +188,6 @@ class MajunOperate: ] = f"{REPO_BASE_URL}{branch_name}/EPOL/update_{release_date}/multi_version/{folder_name}/" return self.send_data_test_platform(update_data, majun_id) - @staticmethod - def jenkins_server( - params, - paral_num=MAX_PARAL_NUM, - release_date="", - branch_name="", - ): - """ - Description: to get the jenkins server - Args: - params: Command line parameters - paral_num: paral num of jenkins job - branch_name: branch name of release issue - release_date: date of release - - Returns: - jenkins server object - """ - jenkins_server = JenkinsJob( - constant.JENKINS_BASE_URL, - params.jenkinsuser, - params.jenkinskey, - paral_num, - branch_name, - release_date, - ) - return jenkins_server - def transfer_pkg_rpm(self, *args, pkgs=None): """ transfer the rpm package to the server, and comment on the Jenkins @@ -271,6 +271,25 @@ class MajunOperate: ) return send_content_majun(self.judge_result(jenkins_obs_res), params.id) + @catch_majun_error + def synchronous_info(self, params): + """ + Call cvrf synchronization and updateinfo to synchronize the jenkins project + Args: + params: Incoming parameter + + Returns: + jenkins runs the result back to majun + """ + self.jenkins_server_obj = self.jenkins_server(params) + jenkins_params = dict( + server=params.server, bucketname=params.bucketname, ipaddr=params.ipaddr + ) + sync_func_map = {"cvrf": "single", "updateinfo": "single", "all": "all"} + return getattr(self, "_{}_sync".format(sync_func_map.get(params.choice)))( + params, jenkins_params + ) + def _all_sync(self, params, jenkins_params): """ Call both the cvrf and update info tasks @@ -304,25 +323,6 @@ class MajunOperate: # Send data to majun return send_content_majun(jenkins_result, params.id) - @catch_majun_error - def synchronous_info(self, params): - """ - Call cvrf synchronization and updateinfo to synchronize the jenkins project - Args: - params: Incoming parameter - - Returns: - jenkins runs the result back to majun - """ - self.jenkins_server_obj = self.jenkins_server(params) - jenkins_params = dict( - server=params.server, bucketname=params.bucketname, ipaddr=params.ipaddr - ) - sync_func_map = {"cvrf": "single", "updateinfo": "single", "all": "all"} - return getattr(self, "_{}_sync".format(sync_func_map.get(params.choice)))( - params, jenkins_params - ) - def _normal_repo(self, branch_name, release_date, obs_project, params): """ Daily operation repo @@ -363,7 +363,7 @@ class MajunOperate: data = True return send_content_majun(data, params.id) - def _multi_repo(self, branch_name, release_date, obs_project, params, folder_name): + def _multi_repo(self, *args): """ Multi-version operation repo Args: @@ -376,6 +376,7 @@ class MajunOperate: Returns: Send data to majun """ + branch_name, release_date, obs_project, params, folder_name = args if obs_project not in OBS_PROJECT_MULTI_VERSION_MAP.keys(): raise ValueError( "If the package has multiple versions, package_family must have a value" -- Gitee From fb5b0ce11a0adf6911ee29c00c7bb81bd219cd59 Mon Sep 17 00:00:00 2001 From: e Date: Fri, 23 Dec 2022 16:55:43 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E6=93=8D=E4=BD=9C=20repo,=E5=8F=91?= =?UTF-8?q?=E9=80=81=E6=95=B0=E6=8D=AE=E7=BB=99=E6=B5=8B=E8=AF=95=E5=B9=B3?= =?UTF-8?q?=E5=8F=B0,cvrf=E5=92=8Cupdate=20info=20=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../javcra/application/majun/majunoperate.py | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/release-assistant/javcra/application/majun/majunoperate.py b/release-assistant/javcra/application/majun/majunoperate.py index c577287..39f462c 100644 --- a/release-assistant/javcra/application/majun/majunoperate.py +++ b/release-assistant/javcra/application/majun/majunoperate.py @@ -249,28 +249,6 @@ class MajunOperate: ) return send_content_majun(self.judge_result(stand_transfer_res), params.id) - def _single_sync(self, params, jenkins_params): - """ - cvrf or update info jenkins job - Args: - params: incoming params - jenkins_params: jenkins params - - Returns: - send data to majun - """ - if params.choice == "cvrf": - jenkins_params.update({"filename": params.cvrffilename}) - else: - jenkins_params.update({"filename": params.updatefilename}) - jenkins_job = ( - CVRF_JOB_NAME if params.choice == "cvrf" else CVE_UPDATE_INFO_JOB_NAME - ) - jenkins_obs_res = self.jenkins_server_obj.get_specific_job_comment( - jenkins_params, jenkins_job - ) - return send_content_majun(self.judge_result(jenkins_obs_res), params.id) - @catch_majun_error def synchronous_info(self, params): """ @@ -400,3 +378,25 @@ class MajunOperate: else: data = True return send_content_majun(data, params.id) + + def _single_sync(self, params, jenkins_params): + """ + cvrf or update info jenkins job + Args: + params: incoming params + jenkins_params: jenkins params + + Returns: + send data to majun + """ + if params.choice == "cvrf": + jenkins_params.update({"filename": params.cvrffilename}) + else: + jenkins_params.update({"filename": params.updatefilename}) + jenkins_job = ( + CVRF_JOB_NAME if params.choice == "cvrf" else CVE_UPDATE_INFO_JOB_NAME + ) + jenkins_obs_res = self.jenkins_server_obj.get_specific_job_comment( + jenkins_params, jenkins_job + ) + return send_content_majun(self.judge_result(jenkins_obs_res), params.id) -- Gitee
File Name  ↓ File Size  ↓ Date  ↓ 
--
-2021-Jul-23 11:58