Coverage for veracode/veracode.py : 100%
Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
|
#!/usr/bin/env python3 Integrate with Veracode's SAST APIs to submit artifacts for scanning and check compliance """
# built-ins
# custom
"""Parse the arguments""" description="Parse arguments to construct Veracode API environmental dicts" ) "--app-id", type=str, help="Application ID as provided by Veracode", default=os.environ.get("VERACODE_APP_ID", None), ) "--build-dir", type=lambda p: Path(p).absolute(), help="A Path where the build artifacts exist, defaults to /build", default=Path("/build").absolute(), ) "--build-id", type=str, help="Application build id", default=os.environ.get("VERACODE_BUILD_ID", None), ) "--disable-auto-scan", action="store_true", help="Disable auto_scan" ) "--disable-scan-nonfatal-modules", action="store_true", help="Disable scan_all_nonfatal_top_level_modules", ) "--version", action="version", version=__version__ ) "--api-key-id", type=str, default=os.environ.get("VERACODE_API_KEY_ID", None), help="Veracode API Key ID", ) "--api-key-secret", type=str, default=os.environ.get("VERACODE_API_KEY_SECRET", None), help="Veracode API Key Secret", )
"--debug", action="store_const", dest="loglevel", const=logging.DEBUG, default=logging.WARNING, help="Enable debug level logging", ) "--verbose", action="store_const", dest="loglevel", const=logging.INFO, default=logging.WARNING, help="Enable info level logging", )
"""Build the results_vapi dict""" # Last updated on 2019-10-22: # https://help.veracode.com/reader/LMv_dtSHyb7iIxAQznC~9w/Mp2BEkLx6rD87k465BWqQg "detailedreport.do": "5.0", "detailedreportpdf.do": "4.0", "getaccountcustomfieldlist.do": "5.0", "getappbuilds.do": "4.0", "getcallstacks.do": "5.0", "summaryreport.do": "4.0", "summaryreportpdf.do": "4.0", "thirdpartyreportpdf.do": "4.0", }
*, app_id: str, build_dir: Path, build_id: str, auto_scan: bool, scan_all_nonfatal_top_level_modules: bool, api_key_id: str, api_key_secret: str ) -> dict: """ Build the upload_vapi dict """ # Last updated on 2019-10-22: # https://help.veracode.com/reader/LMv_dtSHyb7iIxAQznC~9w/G1Nd5yH0QSlT~vPccPhtRQ "beginprescan.do": "5.0", "beginscan.do": "5.0", "createapp.do": "5.0", "createbuild.do": "5.0", "deleteapp.do": "5.0", "deletebuild.do": "5.0", "getappinfo.do": "5.0", "getapplist.do": "5.0", "getbuildinfo.do": "5.0", "getbuildlist.do": "5.0", "getfilelist.do": "5.0", "getpolicylist.do": "5.0", "getprescanresults.do": "5.0", "getvendorlist.do": "5.0", "removefile.do": "5.0", "updateapp.do": "5.0", "updatebuild.do": "5.0", "uploadfile.do": "5.0", "uploadlargefile.do": "5.0", } "scan_all_nonfatal_top_level_modules" ] = scan_all_nonfatal_top_level_modules
""" CI/CD integration with Veracode for SAST """ # Parse the provided arguments
# Extract variables from the provided arguments
# Setup the root logger
# Ensure that the required information was somehow set "An application ID must be provided via the VERACODE_APP_ID environment variable or --app-id command line argument" ) "A build ID must be provided via the VERACODE_BUILD_ID environment variable or --build-id command line argument" ) "An API key ID must be provided via the VERACODE_API_KEY_ID environment variable or --api-key-id command line argument" ) "An API key secret must be provided via the VERACODE_API_KEY_SECRET environment variable or --api-key-secret command line argument" )
# Build the environmental dicts app_id=app_id, api_key_id=api_key_id, api_key_secret=api_key_secret ) app_id=app_id, build_dir=build_dir, build_id=build_id, auto_scan=auto_scan, scan_all_nonfatal_top_level_modules=scan_all_nonfatal_top_level_modules, api_key_id=api_key_id, api_key_secret=api_key_secret, )
else:
else:
if __name__ == "__main__": main() |