appknox.client

class appknox.client.ApiResource(request_session: object, host: str = 'https://api.appknox.com', headers: object | None = None, auth: Dict[str, str] | None = None)[source]

Class to perform API requests

direct_get_http_response(url: str, **kwargs) Response[source]

Return the raw HTTP Response from a given absolute URL

class appknox.client.Appknox(username: str | None = None, password: str | None = None, user_id: int | None = None, organization_id: int | None = None, token: str | None = None, access_token: str | None = None, host: str = 'https://api.appknox.com', log_level: int = 20, http_proxy: str | None = None, https_proxy: str | None = None, insecure: bool = False)[source]

Client to interact with API server

create_report(file_id: int) Report[source]

Create a Report object and returns a report ID. The report ID can then be used to download reports in different formats.

download_report_data(url: str) bytes[source]

Downloads the resppnse body in bytes format for a given absolute URL

generate_access_token()[source]

Generates personal access token

get_analyses(file_id: int) List[Analysis][source]

List analyses for file

Parameters:

file_id – File ID

get_file(file_id: int) File[source]

Fetch file by file ID :param file_id: File ID

get_files(project_id: int, version_code: int | None = None) List[File][source]

List files in project

Parameters:

project_id – Project ID

get_last_file(project_id: int, version_code: int | None = None) File[source]

Fetch latest file for the project

Parameters:

project_id – Project ID

get_organization_id(organization_id: int | None = None) int[source]

Return organization id if exists otherwise first entry of organizations

get_organizations() List[Organization][source]

List organizations for currently authenticated user

get_owasp(owasp_id: str) OWASP[source]

Fetch OWASP by ID

Parameters:

owasp_id – OWASP ID

get_pcidss(pcidss_id: str) PCIDSS[source]

Fetch pcidss by ID

Parameters:

pcidss_id – pcidss ID

get_profile_report_preference(profile_id: int) ProfileReportPreference[source]

Fetch profile report preference

get_project(project_id: int) Project[source]

Fetch project by project ID

Parameters:

project_id – Project ID

get_projects(platform: int | None = None, package_name: str = '', search: str = '') List[Project][source]

List projects for currently authenticated user in the given organizations

get_summary_csv_report_url(report_id: int) str[source]

Returns the absolute URL to download Report Summary in CSV format

get_summary_excel_report_url(report_id: int) str[source]

Returns the absolute URL to download Report Summary in Excel format

get_unselected_report_preference(file_id: int) list[source]

Get a list of unselected report preference items

get_user(user_id: int) User[source]

Fetch user by user ID :param user_id: User ID

get_vulnerability(vulnerability_id: int) Vulnerability[source]

Fetch vulnerability by vulnerability ID

Parameters:

vulnerability_id – vulnerability ID

get_whoami() Whoami[source]

Show session info

list_reports(file_id: int) List[Report][source]

Lists the latest reports for a given file ID

login(otp: int | None = None)[source]

Authenticate with server and create session

Parameters:

otp – One-time password, if account has MFA enabled

poll_for_file_from_submission_id(submission_id: int) int[source]

Using the submission id, keep checking its status. Returns file instance when it’s available

Parameters:

submission_id

The ID of the submission object created for the scan

return:

The File ID

recent_uploads() List[Submission][source]

List details of recent file uploads

rescan(file_id: int) int[source]

Start a rescan for a file id

Parameters:

filed_id – File ID

Returns:

The ID of the File created in rescan

revoke_access_token()[source]

Revokes existing personal access token

switch_organization(organization_id: int | None = None) bool[source]

Switch organization_id of client instance

upload_file(file_data: str) int[source]

Upload and scan a package and returns the file_id

Parameters:

file – Package file content to be uploaded and scanned

write_data_to_file(data: bytes, output_file_path: str) None[source]

Write any data in bytes format to a given file location