From 7a1f78bd259abc9d8cb646f0583ae3ed5665079d Mon Sep 17 00:00:00 2001 From: hyeinlee Date: Wed, 10 Jul 2024 14:27:10 +0900 Subject: [PATCH 1/8] [Fix] Fix api call method from put to post --- src/client.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/client.py b/src/client.py index 91e9123..e6162f8 100644 --- a/src/client.py +++ b/src/client.py @@ -64,13 +64,13 @@ def update_project_watchers(self, prjId, emailList: List[str]): def update_project_models(self, prjId, modelListToUpdate: str): # modelListToUpdate: "Name1|AV/Car/Security > AV|20201010,Name2|AV/Car/Security > AV|20201010" params = {"modelListToUpdate": modelListToUpdate} - return self.put(f'/api/v2/projects/{prjId}/models', params=params) + return self.post(f'/api/v2/projects/{prjId}/models', params=params) def update_project_model_file(self, prjId, modelReport: bytes): files = { "modelReport": modelReport, } - return self.put(f'/api/v2/projects/{prjId}/models/upload', files=files) + return self.post(f'/api/v2/projects/{prjId}/models/upload', files=files) def update_project_bin( self, @@ -88,7 +88,7 @@ def update_project_bin( "resetFlag": resetFlag, "comment": comment, } - return self.put(f'/api/v2/projects/{prjId}/bin', data=data, files=files) + return self.post(f'/api/v2/projects/{prjId}/bin', data=data, files=files) def update_project_src(self, prjId: int, ossReport: Optional[bytes] = None, comment: Optional[str] = None, resetFlag: Optional[str] = None): files = {"ossReport": ossReport} @@ -175,7 +175,7 @@ def get_partner_list( def update_partner_watchers(self, partnerId: int, emailList: List[str]): data = {"emailList": emailList} - return self.put(f"/api/v2/partners/{partnerId}/watchers", data=data) + return self.post(f"/api/v2/partners/{partnerId}/watchers", data=data) def get_max_vulnerability(self, ossName: str, ossVersion: Optional[str] = None): params = { @@ -206,10 +206,10 @@ def update_self_check_report(self, selfCheckId: int, ossReport: bytes=None, rese data = { "resetFlag": resetFlag } - return self.put(f'/api/v2/selfchecks/{selfCheckId}/report', files=files, data=data) + return self.post(f'/api/v2/selfchecks/{selfCheckId}/report', files=files, data=data) def update_self_check_watchers(self, selfCheckId: int, emailList: List[str]): - return self.put(f'/api/v2/selfchecks/{selfCheckId}/watchers', data={"emailList": emailList}) + return self.post(f'/api/v2/selfchecks/{selfCheckId}/watchers', data={"emailList": emailList}) def export_self_check(self, selfCheckId: int): return self.get(f'/api/v2/selfchecks/{selfCheckId}/export') From a1ad30fe8b4ffc6b6753fb5ec8d2f65fb5c7b5a1 Mon Sep 17 00:00:00 2001 From: hyeinlee Date: Wed, 10 Jul 2024 15:56:11 +0900 Subject: [PATCH 2/8] [Fix] Fix create project api parameter: comment to additionalInformation --- src/client.py | 4 ++-- src/commands/create.py | 6 +++--- src/services/project.py | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/client.py b/src/client.py index e6162f8..73d872c 100644 --- a/src/client.py +++ b/src/client.py @@ -34,7 +34,7 @@ def create_project( osTypeEtc: Optional[str] = None, prjVersion: Optional[str] = None, publicYn: Optional[str] = None, - comment: Optional[str] = None, + additionalInformation: Optional[str] = None, userComment: Optional[str] = None, watcherEmailList: Optional[List[str]] = None, modelListToUpdate: Optional[List[str]] = None, @@ -49,7 +49,7 @@ def create_project( "osTypeEtc": osTypeEtc, "prjVersion": prjVersion, "publicYn": publicYn, - "comment": comment, + "additionalInformation": additionalInformation, "userComment": userComment, "watcherEmailList": watcherEmailList, "modelListToUpdate": modelListToUpdate, diff --git a/src/commands/create.py b/src/commands/create.py index cb58e7f..e0a8eb2 100644 --- a/src/commands/create.py +++ b/src/commands/create.py @@ -20,7 +20,7 @@ def create(): @click.option('--osTypeEtc', 'osTypeEtc', help="") @click.option('--prjVersion', 'prjVersion', help="") @click.option('--publicYn', 'publicYn', help="") -@click.option('--comment', 'comment', help="") +@click.option('--additionalInformation', 'additionalInformation', help="") @click.option('--userComment', 'userComment', help="") @click.option('--watcherEmailList', 'watcherEmailList', help="") @click.option('--modelListToUpdate', 'modelListToUpdate', help="") @@ -34,7 +34,7 @@ def create_project( osTypeEtc, prjVersion, publicYn, - comment, + additionalInformation, userComment, watcherEmailList, modelListToUpdate, @@ -49,7 +49,7 @@ def create_project( osTypeEtc=osTypeEtc, prjVersion=prjVersion, publicYn=publicYn, - comment=comment, + additionalInformation=additionalInformation, userComment=userComment, watcherEmailList=watcherEmailList, modelListToUpdate=modelListToUpdate, diff --git a/src/services/project.py b/src/services/project.py index 20053f1..fe2bc9e 100644 --- a/src/services/project.py +++ b/src/services/project.py @@ -21,7 +21,7 @@ def create( osTypeEtc=None, prjVersion=None, publicYn=None, - comment=None, + additionalInformation=None, userComment=None, watcherEmailList=None, modelListToUpdate=None, @@ -36,7 +36,7 @@ def create( osTypeEtc=osTypeEtc, prjVersion=prjVersion, publicYn=publicYn, - comment=comment, + additionalInformation=additionalInformation, userComment=userComment, watcherEmailList=watcherEmailList, modelListToUpdate=modelListToUpdate, From 463f66f14749850eb31cb43769dcd7577cae8ca8 Mon Sep 17 00:00:00 2001 From: hyeinlee Date: Wed, 10 Jul 2024 16:20:40 +0900 Subject: [PATCH 3/8] [Fix] Fix function name typo when update selfcheck watcher function call --- src/services/self_check.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/self_check.py b/src/services/self_check.py index a444a3f..a6b5fa6 100644 --- a/src/services/self_check.py +++ b/src/services/self_check.py @@ -30,7 +30,7 @@ def update_report(self, selfCheckId, ossReport=None, resetFlag=None): check_response(response) def update_watchers(self, selfCheckId, emailList): - response = get_api_client().update_selfCheck_watchers( + response = get_api_client().update_self_check_watchers( selfCheckId=selfCheckId, emailList=emailList, ) From 108fca8e52916deaf93e23389b1eac52ebe4452b Mon Sep 17 00:00:00 2001 From: hyeinlee Date: Wed, 10 Jul 2024 16:41:50 +0900 Subject: [PATCH 4/8] [Fix] Fix parameter name typo in update partner watcher api --- src/commands/update.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/update.py b/src/commands/update.py index d03dc3f..4fc4051 100644 --- a/src/commands/update.py +++ b/src/commands/update.py @@ -139,7 +139,7 @@ def update_self_check_watchers(selfCheckId, emailList): def update_partner_watchers(partnerId, emailList): client = get_api_client() response = client.update_partner_watchers( - partnersId=partnerId, + partnerId=partnerId, emailList=emailList, ) check_response(response) From 5b6d7be3d6f90d960f7e0b411d2abe86610aa861 Mon Sep 17 00:00:00 2001 From: hyeinlee Date: Thu, 11 Jul 2024 11:04:21 +0900 Subject: [PATCH 5/8] [Fix] Add parameter in license and oss search to get all list --- src/client.py | 11 +++++++++-- src/commands/get.py | 22 +++++++++++++++++----- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/src/client.py b/src/client.py index 73d872c..b50ff21 100644 --- a/src/client.py +++ b/src/client.py @@ -142,15 +142,22 @@ def export_project_bom_json(self, prjId: int): def export_project_notice(self, prjId: str): return self.get(f'/api/v2/projects/{prjId}/notice') - def get_license_list(self, licenseName: str): + def get_license_list(self, licenseName: Optional[str] = None, licenseNameExact: Optional[str] = None, + countPerPage: Optional[str] = None, page: Optional[str] = None): data = {"licenseName": licenseName} return self.get('/api/v2/licenses', params=data) - def get_oss(self, ossName: str, ossVersion: Optional[str] = None, downloadLocation: Optional[str] = None): + def get_oss(self, ossName: Optional[str] = None, ossNameExact: Optional[str] = None, ossVersion: Optional[str] = None, + downloadLocation: Optional[str] = None, downloadLocationExact: Optional[str] = None, + countPerPage: Optional[str] = None, page: Optional[str] = None): params = { "ossName": ossName, + "ossNameExact": ossNameExact, "ossVersion": ossVersion, "downloadLocation": downloadLocation, + "downloadLocationExact": downloadLocationExact, + "countPerPage": countPerPage, + "page": page, } return self.get('/api/v2/oss', params=params) diff --git a/src/commands/get.py b/src/commands/get.py index 467b58a..4a8c3dc 100644 --- a/src/commands/get.py +++ b/src/commands/get.py @@ -95,10 +95,14 @@ def get_self_check_detail(id): # license @get_license.command("list") -@click.option("--licenseName", "licenseName", required=True, help="license name") -def get_license_list(licenseName): +@click.option("--licenseName", "licenseName", help="license name") +@click.option("--licenseNameExact", "licenseNameExact", help="license name exact match flag") +@click.option("--count", "countPerPage", help="item count per page") +@click.option("--page", "page", help="page number") +def get_license_list(licenseName, licenseNameExact, countPerPage, page): client = get_api_client() - response = client.get_license_list(licenseName=licenseName) + response = client.get_license_list(licenseName=licenseName, licenseNameExact=licenseNameExact, + countPerPage=countPerPage, page=page) if response.status_code == 404: display_text("Not found") return @@ -108,15 +112,23 @@ def get_license_list(licenseName): # oss @get_oss.command("list") -@click.option("--ossName", "ossName", required=True, help="oss name") +@click.option("--ossName", "ossName", help="oss name") +@click.option("--ossNameExact", "ossNameExact", help="oss name exact match flag") @click.option("--ossVersion", "ossVersion", help="oss version") @click.option("--downloadLocation", "downloadLocation", help="download location") -def get_oss_list(ossName, ossVersion, downloadLocation): +@click.option("--downloadLocationExact", "downloadLocationExact", help="download location exact match flag") +@click.option("--count", "countPerPage", help="item count per page") +@click.option("--page", "page", help="page number") +def get_oss_list(ossName, ossNameExact, ossVersion, downloadLocation, downloadLocationExact, countPerPage, page): client = get_api_client() response = client.get_oss( ossName=ossName, + ossNameExact=ossNameExact, ossVersion=ossVersion, downloadLocation=downloadLocation, + downloadLocationExact=downloadLocationExact, + countPerPage=countPerPage, + page=page ) check_response(response) pretty_print_dict(response.json()) From ff426ec5201de5fc5ffc26f67788d59008fc01ad Mon Sep 17 00:00:00 2001 From: hyeinlee00 Date: Fri, 12 Jul 2024 15:34:35 +0900 Subject: [PATCH 6/8] [Imporve] Change export file name to include prjid --- src/commands/export.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/commands/export.py b/src/commands/export.py index 2c76d0b..a6db18a 100644 --- a/src/commands/export.py +++ b/src/commands/export.py @@ -25,7 +25,7 @@ def export_project(): @click.option("--output", "-o", "output", help="output file path") def export_project_bom(prjId, mergeSaveFlag, output): response = ProjectService().export_bom(prjId, mergeSaveFlag) - path = output if output else f"bom_{int(datetime.datetime.now().timestamp())}.xlsx" + path = output if output else f"fosslight_report_{int(datetime.datetime.now().timestamp())}_project-{prjId}.xlsx" if not path.endswith(".xlsx"): path += ".xlsx" with open(path, "wb") as f: @@ -45,7 +45,7 @@ def export_project_bom_json(prjId): @click.option("--output", "-o", "output", help="output file path") def export_project_notice(prjId, output): response = ProjectService().export_notice(prjId) - path = output if output else f"notice_{int(datetime.datetime.now().timestamp())}.html" + path = output if output else f"notice_{int(datetime.datetime.now().timestamp())}_project-{prjId}.html" if not path.endswith(".html"): path += ".html" @@ -58,6 +58,6 @@ def export_project_notice(prjId, output): @click.option("--selfCheckId", "selfCheckId", required=True, help="selfCheck id") def export_self_check(selfCheckId): response = SelfCheckService().export(selfCheckId) - with open(f"bom_{int(datetime.datetime.now().timestamp())}.xlsx", "wb") as f: + with open(f"fosslight_report_{int(datetime.datetime.now().timestamp())}_self-{selfCheckId}.xlsx", "wb") as f: f.write(response.content) display_text("Success: Export self-check") From a65ec6f1bbd2093c17d2009b5e1ad58bcb9a42ea Mon Sep 17 00:00:00 2001 From: hyeinlee00 Date: Tue, 16 Jul 2024 14:33:44 +0900 Subject: [PATCH 7/8] [Fix] Update scanner version and modify scanner call parameter --- requirements.txt | 4 ++-- src/scanner.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/requirements.txt b/requirements.txt index 83bb20e..f8d01fd 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ click==8.1.7 requests==2.31.0 dataclasses==0.6 -fosslight_scanner==1.7.20 -PyYAML==6.0.1 \ No newline at end of file +fosslight_scanner +PyYAML==6.0.1 diff --git a/src/scanner.py b/src/scanner.py index 27a15ef..6243a85 100644 --- a/src/scanner.py +++ b/src/scanner.py @@ -16,7 +16,7 @@ def scan_all(cls, path: str) -> ScanResult: uid = uuid.uuid4() output_path = os.path.expanduser(f'{cls.BASE_PATH}/{uid}') run_main( - mode='all', + mode_list=["all"], path_arg=[path], dep_arguments='', output_file_or_dir=output_path, From cbc06e7495113e38177af7b268e371741b5c93d5 Mon Sep 17 00:00:00 2001 From: hyeinlee00 Date: Mon, 22 Jul 2024 15:05:49 +0900 Subject: [PATCH 8/8] [Update] Update CLI version to 1.0.0 --- setup.py | 2 +- src/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 1ccbd00..daaaf73 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ if __name__ == '__main__': setup( name='fosslight_cli', - version='0.0.6', + version='1.0.0', packages=find_packages(), install_requires=required, python_requires=">=3.8", diff --git a/src/__init__.py b/src/__init__.py index fa9c4ec..1f356cc 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -1 +1 @@ -__version__ = '0.0.6' +__version__ = '1.0.0'