Skip to content

Commit

Permalink
Merge pull request #55 from fosslight/snu
Browse files Browse the repository at this point in the history
v1.0.0
  • Loading branch information
hyeinlee00 authored Jul 22, 2024
2 parents 6b5d9e0 + cbc06e7 commit 325df42
Show file tree
Hide file tree
Showing 11 changed files with 49 additions and 30 deletions.
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
click==8.1.7
requests==2.31.0
dataclasses==0.6
fosslight_scanner==1.7.20
PyYAML==6.0.1
fosslight_scanner
PyYAML==6.0.1
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.0.6'
__version__ = '1.0.0'
27 changes: 17 additions & 10 deletions src/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -49,7 +49,7 @@ def create_project(
"osTypeEtc": osTypeEtc,
"prjVersion": prjVersion,
"publicYn": publicYn,
"comment": comment,
"additionalInformation": additionalInformation,
"userComment": userComment,
"watcherEmailList": watcherEmailList,
"modelListToUpdate": modelListToUpdate,
Expand All @@ -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,
Expand All @@ -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}
Expand Down Expand Up @@ -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)

Expand All @@ -175,7 +182,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 = {
Expand Down Expand Up @@ -206,10 +213,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')
Expand Down
6 changes: 3 additions & 3 deletions src/commands/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -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="")
Expand All @@ -34,7 +34,7 @@ def create_project(
osTypeEtc,
prjVersion,
publicYn,
comment,
additionalInformation,
userComment,
watcherEmailList,
modelListToUpdate,
Expand All @@ -49,7 +49,7 @@ def create_project(
osTypeEtc=osTypeEtc,
prjVersion=prjVersion,
publicYn=publicYn,
comment=comment,
additionalInformation=additionalInformation,
userComment=userComment,
watcherEmailList=watcherEmailList,
modelListToUpdate=modelListToUpdate,
Expand Down
6 changes: 3 additions & 3 deletions src/commands/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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"
Expand All @@ -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")
22 changes: 17 additions & 5 deletions src/commands/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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())
Expand Down
2 changes: 1 addition & 1 deletion src/commands/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/services/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def create(
osTypeEtc=None,
prjVersion=None,
publicYn=None,
comment=None,
additionalInformation=None,
userComment=None,
watcherEmailList=None,
modelListToUpdate=None,
Expand All @@ -36,7 +36,7 @@ def create(
osTypeEtc=osTypeEtc,
prjVersion=prjVersion,
publicYn=publicYn,
comment=comment,
additionalInformation=additionalInformation,
userComment=userComment,
watcherEmailList=watcherEmailList,
modelListToUpdate=modelListToUpdate,
Expand Down
2 changes: 1 addition & 1 deletion src/services/self_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down

0 comments on commit 325df42

Please sign in to comment.