prismacloud-api-python icon indicating copy to clipboard operation
prismacloud-api-python copied to clipboard

Add _serverless.py to get serverless vulnerability information

Open ipalvr opened this issue 1 year ago • 2 comments

Is your feature request related to a problem?

I have a customer who is automating serverless vulnerability reporting and they would like to leverage a script like the one we have for hosts. Here is the path to the hosts example. prismacloud-api-python/prismacloud/api/cwpp/_hosts.py

Describe the solution you'd like

Support for serverless vulnerability reporting.

Describe alternatives you've considered

No alternatives at this point

Additional context

Customer is unable to leverage the api to automate vulnerability reporting like they do for hosts and containers.

ipalvr avatar Feb 11 '24 18:02 ipalvr

Create a new file. File name: _serverless.py. Store this file in prismacloud-api-python/prismacloud/api/cwpp

# Serverless
 class ServerlessPrismaCloudAPICWPPMixin:

    """ Prisma Cloud Compute Serverless Endpoints Class """

    # Get serverless function scan results
    def serverless_list_read(self, query_params=None):
        result = self.execute_compute('GET', 'api/v1/serverless', query_params=query_params, paginated=True)
        return result 

    # Download serverless function scan results   
    def serverless_download(self, query_params=None):
        result = self.execute_compute('GET', 'api/v1/serverless/download?', query_params=query_params)
        return result

    # Start serverless function scan
    def serverless_start_scan(self):
        result = self.execute_compute('POST', 'api/v1/serverless/scan')
        return result

    # Stop serverless function scan
    def serverless_stop_scan(self):
        result = self.execute_compute('POST', 'api/v1/serverless/stop')
        return result

tgorman1000 avatar Feb 12 '24 21:02 tgorman1000

Add the following to the prismacloud-api-python/prismacloud/api/cwpp/init.py file:

from ._serverless import *

tgorman1000 avatar Feb 15 '24 15:02 tgorman1000