Search is not available for this dataset
text
stringlengths
75
104k
async def get_bots(self, limit, offset): '''Gets an object of bots on DBL''' if limit > 500: limit = 50 return await self.request('GET', '{}/bots?limit={}&offset={}'.format(self.BASE, limit, offset))
def guild_count(self): """Gets the guild count from the Client/Bot object""" try: return len(self.bot.guilds) except AttributeError: return len(self.bot.servers)
async def post_guild_count( self, shard_count: int = None, shard_no: int = None ): """This function is a coroutine. Posts the guild count to discordbots.org .. _0 based indexing : https://en.wikipedia.org/wiki/Zero-based_numbering Parameters ...
async def get_guild_count(self, bot_id: int=None): """This function is a coroutine. Gets a guild count from discordbots.org Parameters ========== bot_id: int[Optional] The bot_id of the bot you want to lookup. Defaults to the Bot provided in Client init...
async def get_bot_info(self, bot_id: int = None): """This function is a coroutine. Gets information about a bot from discordbots.org Parameters ========== bot_id: int[Optional] The bot_id of the bot you want to lookup. Returns ======= bot_...
async def get_bots(self, limit: int = 50, offset: int = 0): """This function is a coroutine. Gets information about listed bots on discordbots.org Parameters ========== limit: int[Optional] The number of results you wish to lookup. Defaults to 50. Max 500. ...
async def generate_widget_large( self, bot_id: int = None, top: str = '2C2F33', mid: str = '23272A', user: str = 'FFFFFF', cert: str = 'FFFFFF', data: str = 'FFFFFF', label: str = '99AAB5', highlight: str = '2C2F...
async def get_widget_large(self, bot_id: int = None): """This function is a coroutine. Generates the default large widget. Parameters ========== bot_id: int The bot_id of the bot you wish to make a widget for. Returns ======= URL of the wi...
async def generate_widget_small( self, bot_id: int = None, avabg: str = '2C2F33', lcol: str = '23272A', rcol: str = '2C2F33', ltxt: str = 'FFFFFF', rtxt: str = 'FFFFFF' ): """This function is a coroutine. Generates ...
async def get_widget_small(self, bot_id: int = None): """This function is a coroutine. Generates the default small widget. Parameters ========== bot_id: int The bot_id of the bot you wish to make a widget for. Returns ======= URL of the wi...
async def close(self): """This function is a coroutine. Closes all connections.""" if self._is_closed: return else: await self.http.close() self._is_closed = True
def read(self): """Read incoming message.""" packet = self.packet with self.__read_lock: buffer = self.__buffer while len(buffer) < packet: buffer += self._read_data() length = self.__unpack(buffer[:packet])[0] + packet while len(bu...
def write(self, message): """Write outgoing message.""" data = encode(message, compressed=self.compressed) length = len(data) data = self.__pack(length) + data with self.__write_lock: while data: try: n = os.write(self.out_d, data) ...
def close(self): """Close port.""" os.close(self.in_d) os.close(self.out_d)
def decode(string): """Decode Erlang external term.""" if not string: raise IncompleteData(string) if string[0] != 131: raise ValueError("unknown protocol version: %r" % string[0]) if string[1:2] == b'P': # compressed term if len(string) < 16: raise Incomplete...
def encode(term, compressed=False): """Encode Erlang external term.""" encoded_term = encode_term(term) # False and 0 do not attempt compression. if compressed: if compressed is True: # default compression level of 6 compressed = 6 elif compressed < 0 or compresse...
def get_default_falco_rules_files(self): '''**Description** Get the set of falco rules files from the backend. The _files programs and endpoints are a replacement for the system_file endpoints and allow for publishing multiple files instead of a single file as well as p...
def save_default_falco_rules_files(self, fsobj, save_dir): '''**Description** Given a dict returned from get_default_falco_rules_files, save those files to a set of files below save_dir. The first level below save_dir is a directory with the tag name. The second level is a directory p...
def load_default_falco_rules_files(self, save_dir): '''**Description** Given a file and directory layout as described in save_default_falco_rules_files(), load those files and return a dict representing the contents. This dict is suitable for passing to set_default_falco_rules_files(). ...
def get_policy_events_duration(self, duration_sec, sampling=None, aggregations=None, scope_filter=None, event_filter=None): '''**Description** Fetch all policy events that occurred in the last duration_sec seconds. This method is used in conjunction with :func:`~sdcclient.SdSecureClient....
def get_policy_events_id_range(self, id, from_sec, to_sec, sampling=None, aggregations=None, scope_filter=None, event_filter=None): '''**Description** Fetch all policy events with id that occurred in the time range [from_sec:to_sec]. This method is used in conjunction with :func:`~sdccli...
def create_default_policies(self): '''**Description** Create a set of default policies using the current system falco rules file as a reference. For every falco rule in the system falco rules file, one policy will be created. The policy will take the name and description from the name an...
def delete_all_policies(self): '''**Description** Delete all existing policies. The falco rules file is unchanged. **Arguments** - None **Success Return Value** The string "Policies Deleted" **Example** `examples/delete_all_policies.py <...
def set_policy_priorities(self, priorities_json): '''**Description** Change the policy evaluation order **Arguments** - priorities_json: a description of the new policy order. **Success Return Value** A JSON object representing the updated list of policy ids...
def get_policy(self, name): '''**Description** Find the policy with name <name> and return its json description. **Arguments** - name: the name of the policy to fetch **Success Return Value** A JSON object containing the description of the policy. If there i...
def add_policy(self, policy_json): '''**Description** Add a new policy using the provided json. **Arguments** - policy_json: a description of the new policy **Success Return Value** The string "OK" **Example** `examples/add_policy.py <ht...
def delete_policy_name(self, name): '''**Description** Delete the policy with the given name. **Arguments** - name: the name of the policy to delete **Success Return Value** The JSON object representing the now-deleted policy. **Example** ...
def delete_policy_id(self, id): '''**Description** Delete the policy with the given id **Arguments** - id: the id of the policy to delete **Success Return Value** The JSON object representing the now-deleted policy. **Example** `examples...
def add_compliance_task(self, name, module_name='docker-bench-security', schedule='06:00:00Z/PT12H', scope=None, enabled=True): '''**Description** Add a new compliance task. **Arguments** - name: The name of the task e.g. 'Check Docker Compliance'. - module_name: The...
def list_compliance_tasks(self): '''**Description** Get the list of all compliance tasks. **Arguments** - None **Success Return Value** A JSON list with the representation of each compliance task. ''' res = requests.get(self.url + '/api/compl...
def get_compliance_task(self, id): '''**Description** Get a compliance task. **Arguments** - id: the id of the compliance task to get. **Success Return Value** A JSON representation of the compliance task. ''' res = requests.get(self.url + '/...
def update_compliance_task(self, id, name=None, module_name=None, schedule=None, scope=None, enabled=None): '''**Description** Update an existing compliance task. **Arguments** - id: the id of the compliance task to be updated. - name: The name of the task e.g. 'Chec...
def delete_compliance_task(self, id): '''**Description** Delete the compliance task with the given id **Arguments** - id: the id of the compliance task to delete ''' res = requests.delete(self.url + '/api/complianceTasks/{}'.format(id), headers=self.hdrs, verify=...
def list_compliance_results(self, limit=50, direction=None, cursor=None, filter=""): '''**Description** Get the list of all compliance tasks runs. **Arguments** - limit: Maximum number of alerts in the response. - direction: the direction (PREV or NEXT) that determin...
def get_compliance_results_csv(self, id): '''**Description** Retrieve the details for a specific compliance task run result in csv. **Arguments** - id: the id of the compliance task run to get. **Success Return Value** A CSV representation of the compliance ...
def list_commands_audit(self, from_sec=None, to_sec=None, scope_filter=None, command_filter=None, limit=100, offset=0, metrics=[]): '''**Description** List the commands audit. **Arguments** - from_sec: the start of the timerange for which to get commands audit. - end...
def get_command_audit(self, id, metrics=[]): '''**Description** Get a command audit. **Arguments** - id: the id of the command audit to get. **Success Return Value** A JSON representation of the command audit. ''' url = "{url}/api/commands/{i...
def get_notifications(self, from_ts, to_ts, state=None, resolved=None): '''**Description** Returns the list of Sysdig Monitor alert notifications. **Arguments** - **from_ts**: filter events by start time. Timestamp format is in UTC (seconds). - **to_ts**: filter even...
def update_notification_resolution(self, notification, resolved): '''**Description** Updates the resolution status of an alert notification. **Arguments** - **notification**: notification object as returned by :func:`~SdcClient.get_notifications`. - **resolved**: new...
def create_alert(self, name=None, description=None, severity=None, for_atleast_s=None, condition=None, segmentby=[], segment_condition='ANY', user_filter='', notify=None, enabled=True, annotations={}, alert_obj=None): '''**Description** Create a threshold-ba...
def update_alert(self, alert): '''**Description** Update a modified threshold-based alert. **Arguments** - **alert**: one modified alert object of the same format as those in the list returned by :func:`~SdcClient.get_alerts`. **Success Return Value** The up...
def delete_alert(self, alert): '''**Description** Deletes an alert. **Arguments** - **alert**: the alert dictionary as returned by :func:`~SdcClient.get_alerts`. **Success Return Value** ``None``. **Example** `examples/delete_alert.py <h...
def get_explore_grouping_hierarchy(self): '''**Description** Return the user's current grouping hierarchy as visible in the Explore tab of Sysdig Monitor. **Success Return Value** A list containing the list of the user's Explore grouping criteria. **Example** ...
def set_explore_grouping_hierarchy(self, new_hierarchy): '''**Description** Changes the grouping hierarchy in the Explore panel of the current user. **Arguments** - **new_hierarchy**: a list of sysdig segmentation metrics indicating the new grouping hierarchy. ''' ...
def get_dashboards(self): '''**Description** Return the list of dashboards available under the given user account. This includes the dashboards created by the user and the ones shared with her by other users. **Success Return Value** A dictionary containing the list of available...
def find_dashboard_by(self, name=None): '''**Description** Finds dashboards with the specified name. You can then delete the dashboard (with :func:`~SdcClient.delete_dashboard`) or edit panels (with :func:`~SdcClient.add_dashboard_panel` and :func:`~SdcClient.remove_dashboard_panel`) **Argu...
def remove_dashboard_panel(self, dashboard, panel_name): '''**Description** Removes a panel from the dashboard. The panel to remove is identified by the specified ``name``. **Arguments** - **name**: name of the panel to find and remove **Success Return Value** ...
def create_dashboard_from_view(self, newdashname, viewname, filter, shared=False, public=False): '''**Description** Create a new dasboard using one of the Sysdig Monitor views as a template. You will be able to define the scope of the new dashboard. **Arguments** - **newdashname...
def create_dashboard_from_dashboard(self, newdashname, templatename, filter, shared=False, public=False): '''**Description** Create a new dasboard using one of the existing dashboards as a template. You will be able to define the scope of the new dasboard. **Arguments** - **newd...
def create_dashboard_from_file(self, dashboard_name, filename, filter, shared=False, public=False): ''' **Description** Create a new dasboard using a dashboard template saved to disk. See :func:`~SdcClient.save_dashboard_to_file` to use the file to create a dashboard (usefl to create and res...
def save_dashboard_to_file(self, dashboard, filename): ''' **Description** Save a dashboard to disk. See :func:`~SdcClient.create_dashboard_from_file` to use the file to create a dashboard (usefl to create and restore backups). The file will contain a JSON object with the follow...
def delete_dashboard(self, dashboard): '''**Description** Deletes a dashboard. **Arguments** - **dashboard**: the dashboard object as returned by :func:`~SdcClient.get_dashboards`. **Success Return Value** `None`. **Example** `examples/d...
def convert_scope_string_to_expression(scope): '''**Description** Internal function to convert a filter string to a filter object to be used with dashboards. ''' # # NOTE: The supported grammar is not perfectly aligned with the grammar supported by the Sysdig backend. ...
def get_notification_ids(self, channels=None): '''**Description** Get an array of all configured Notification Channel IDs, or a filtered subset of them. **Arguments** - **channels**: an optional array of dictionaries to limit the set of Notification Channel IDs returned. If not ...
def post_event(self, name, description=None, severity=None, event_filter=None, tags=None): '''**Description** Send an event to Sysdig Monitor. The events you post are available in the Events tab in the Sysdig Monitor UI and can be overlied to charts. **Arguments** - **name**: th...
def get_events(self, name=None, from_ts=None, to_ts=None, tags=None): '''**Description** Returns the list of Sysdig Monitor events. **Arguments** - **name**: filter events by name. - **from_ts**: filter events by start time. Timestamp format is in UTC (seconds). ...
def delete_event(self, event): '''**Description** Deletes an event. **Arguments** - **event**: the event object as returned by :func:`~SdcClient.get_events`. **Success Return Value** `None`. **Example** `examples/delete_event.py <https:/...
def get_data(self, metrics, start_ts, end_ts=0, sampling_s=0, filter='', datasource_type='host', paging=None): '''**Description** Export metric data (both time-series and table-based). **Arguments** - **metrics**: a list of dictionaries, specifying the metrics a...
def get_sysdig_captures(self, from_sec=None, to_sec=None, scope_filter=None): '''**Description** Returns the list of sysdig captures for the user. **Arguments** - from_sec: the start of the timerange for which to get the captures - end_sec: the end of the timerange f...
def poll_sysdig_capture(self, capture): '''**Description** Fetch the updated state of a sysdig capture. Can be used to poll the status of a capture that has been previously created and started with :func:`~SdcClient.create_sysdig_capture`. **Arguments** - **capture**: the captur...
def create_sysdig_capture(self, hostname, capture_name, duration, capture_filter='', folder='/'): '''**Description** Create a new sysdig capture. The capture will be immediately started. **Arguments** - **hostname**: the hostname of the instrumented host where the capture will b...
def download_sysdig_capture(self, capture_id): '''**Description** Download a sysdig capture by id. **Arguments** - **capture_id**: the capture id to download. **Success Return Value** The bytes of the scap ''' url = '{url}/api/sysdig/{id}/dow...
def create_user_invite(self, user_email, first_name=None, last_name=None, system_role=None): '''**Description** Invites a new user to use Sysdig Monitor. This should result in an email notification to the specified address. **Arguments** - **user_email**: the email address of th...
def delete_user(self, user_email): '''**Description** Deletes a user from Sysdig Monitor. **Arguments** - **user_email**: the email address of the user that will be deleted from Sysdig Monitor **Example** `examples/user_team_mgmt.py <https://github.com/draio...
def get_teams(self, team_filter=''): '''**Description** Return the set of teams that match the filter specified. The *team_filter* should be a substring of the names of the teams to be returned. **Arguments** - **team_filter**: the team filter to match when returning the list of...
def get_team(self, name): '''**Description** Return the team with the specified team name, if it is present. **Arguments** - **name**: the name of the team to return **Success Return Value** The requested team. **Example** `examples/user...
def create_team(self, name, memberships=None, filter='', description='', show='host', theme='#7BB0B2', perm_capture=False, perm_custom_events=False, perm_aws_data=False): ''' **Description** Creates a new team **Arguments** - **name**: the name of the...
def edit_team(self, name, memberships=None, filter=None, description=None, show=None, theme=None, perm_capture=None, perm_custom_events=None, perm_aws_data=None): ''' **Description** Edits an existing team. All arguments are optional. Team settings for any arguments unspecif...
def delete_team(self, name): '''**Description** Deletes a team from Sysdig Monitor. **Arguments** - **name**: the name of the team that will be deleted from Sysdig Monitor **Example** `examples/user_team_mgmt.py <https://github.com/draios/python-sdc-client/b...
def list_memberships(self, team): ''' **Description** List all memberships for specified team. **Arguments** - **team**: the name of the team for which we want to see memberships **Result** Dictionary of (user-name, team-role) pairs that should descr...
def save_memberships(self, team, memberships): ''' **Description** Create new user team memberships or update existing ones. **Arguments** - **team**: the name of the team for which we are creating new memberships - **memberships**: dictionary of (user-name, ...
def remove_memberships(self, team, users): ''' **Description** Remove user memberships from specified team. **Arguments** - **team**: the name of the team from which user memberships are removed - **users**: list of usernames which should be removed from team...
def create_dashboard(self, name): ''' **Description** Creates an empty dashboard. You can then add panels by using ``add_dashboard_panel``. **Arguments** - **name**: the name of the dashboard that will be created. **Success Return Value** A dictionar...
def add_dashboard_panel(self, dashboard, name, panel_type, metrics, scope=None, sort_by=None, limit=None, layout=None): """**Description** Adds a panel to the dashboard. A panel can be a time series, or a top chart (i.e. bar chart), or a number panel. **Arguments** - **dashboard...
def add_image(self, image, force=False, dockerfile=None, annotations={}, autosubscribe=True): '''**Description** Add an image to the scanner **Arguments** - image: Input image can be in the following formats: registry/repo:tag - dockerfile: The contents of the docker...
def import_image(self, image_data): '''**Description** Import an image from the scanner export **Arguments** - image_data: A JSON with the image information. **Success Return Value** A JSON object representing the image that was imported. ''' ...
def get_image(self, image, show_history=False): '''**Description** Find the image with the tag <image> and return its json description **Arguments** - image: Input image can be in the following formats: registry/repo:tag **Success Return Value** A JSON objec...
def query_image_content(self, image, content_type=""): '''**Description** Find the image with the tag <image> and return its content. **Arguments** - image: Input image can be in the following formats: registry/repo:tag - content_type: The content type can be one of ...
def query_image_metadata(self, image, metadata_type=""): '''**Description** Find the image with the tag <image> and return its metadata. **Arguments** - image: Input image can be in the following formats: registry/repo:tag - metadata_type: The metadata type can be on...
def query_image_vuln(self, image, vuln_type="", vendor_only=True): '''**Description** Find the image with the tag <image> and return its vulnerabilities. **Arguments** - image: Input image can be in the following formats: registry/repo:tag - vuln_type: Vulnerability ...
def delete_image(self, image, force=False): '''**Description** Delete image from the scanner. **Arguments** - None ''' _, _, image_digest = self._discover_inputimage(image) if not image_digest: return [False, "cannot use input image string: no...
def check_image_evaluation(self, image, show_history=False, detail=False, tag=None, policy=None): '''**Description** Check the latest policy evaluation for an image **Arguments** - image: Input image can be in the following formats: registry/repo:tag - show_history: ...
def add_registry(self, registry, registry_user, registry_pass, insecure=False, registry_type="docker_v2", validate=True): '''**Description** Add image registry **Arguments** - registry: Full hostname/port of registry. Eg. myrepo.example.com:5000 - registry_user: User...
def update_registry(self, registry, registry_user, registry_pass, insecure=False, registry_type="docker_v2", validate=True): '''**Description** Update an existing image registry. **Arguments** - registry: Full hostname/port of registry. Eg. myrepo.example.com:5000 - ...
def delete_registry(self, registry): '''**Description** Delete an existing image registry **Arguments** - registry: Full hostname/port of registry. Eg. myrepo.example.com:5000 ''' # do some input string checking if re.match(".*\\/.*", registry): ...
def get_registry(self, registry): '''**Description** Find the registry and return its json description **Arguments** - registry: Full hostname/port of registry. Eg. myrepo.example.com:5000 **Success Return Value** A JSON object representing the registry. ...
def add_policy(self, name, rules, comment="", bundleid=None): '''**Description** Create a new policy **Arguments** - name: The name of the policy. - rules: A list of Anchore PolicyRule elements (while creating/updating a policy, new rule IDs will be created backend s...
def get_policy(self, policyid, bundleid=None): '''**Description** Retrieve the policy with the given id in the targeted policy bundle **Arguments** - policyid: Unique identifier associated with this policy. - bundleid: Target bundle. If not specified, the currently a...
def update_policy(self, policyid, policy_description): '''**Description** Update the policy with the given id **Arguments** - policyid: Unique identifier associated with this policy. - policy_description: A dictionary with the policy description. **Success R...
def add_alert(self, name, description=None, scope="", triggers={'failed': True, 'unscanned': True}, enabled=False, notification_channels=[]): '''**Description** Create a new alert **Arguments** - name: The name of the alert. - description: The descp...
def list_alerts(self, limit=None, cursor=None): '''**Description** List the current set of scanning alerts. **Arguments** - limit: Maximum number of alerts in the response. - cursor: An opaque string representing the current position in the list of alerts. It's provi...
def update_alert(self, alertid, alert_description): '''**Description** Update the alert with the given id **Arguments** - alertid: Unique identifier associated with this alert. - alert_description: A dictionary with the alert description. **Success Return Va...
def delete_alert(self, policyid): '''**Description** Delete the alert with the given id **Arguments** - alertid: Unique identifier associated with this alert. ''' url = self.url + '/api/scanning/v1/alerts/' + policyid res = requests.delete(url, headers=se...
def list_subscription(self): '''**Description** List all subscriptions **Arguments** - None **Success Return Value** A JSON object representing the list of subscriptions. ''' url = self.url + "/api/scanning/v1/anchore/subscriptions" r...
def list_runtime(self, scope="", skip_policy_evaluation=True, start_time=None, end_time=None): '''**Description** List runtime containers **Arguments** - scope: An AND-composed string of predicates that selects the scope in which the alert will be applied. (like: 'host.domain = ...
def addSourceAddr(self, addr): """None means 'system default'""" try: self._multiInSocket.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, self._makeMreq(addr)) except socket.error: # if 1 interface has more than 1 address, exception is raised for the second pass ...
def _sendPendingMessages(self): """Method sleeps, if nothing to do""" if len(self._queue) == 0: time.sleep(0.1) return msg = self._queue.pop(0) if msg.canSend(): self._sendMsg(msg) msg.refresh() if not (msg.isFinished()): ...
def setRemoteServiceHelloCallback(self, cb, types=None, scopes=None): """Set callback, which will be called when new service appeared online and sent Hi message typesFilter and scopesFilter might be list of types and scopes. If filter is set, callback is called only for Hello messages, ...
def stop(self): 'cleans up and stops the discovery server' self.clearRemoteServices() self.clearLocalServices() self._stopThreads() self._serverStarted = False
def clearLocalServices(self): 'send Bye messages for the services and remove them' for service in list(self._localServices.values()): self._sendBye(service) self._localServices.clear()