Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

IconDescription

Python Project, Python External Library
Python Module
Python Class
Python Method
Python Script

Python Get Urllib, Urllib2, Httplib, Httplib2, aiohttp ServicePython Flask, aiohttp Web Service Get OperationGET (urllib, urllib2, httplib, httplib2, aiohttp) service
Python GET service request
Python (Flask, aiohttp) Web Service GET operation

Python Post Urllib, Urllib2, Httplib, Httplib2, aiohttp ServicePython POST (urllib, urllib2, httplib, httplib2, aiohttpservice
Python POST service request
Python (Flask, aiohttp) Web Service Post OperationPOST operation

Python Put Urllib, Httplib, Httplib2, aiohttp ServicePython PUT (urllib, urllib2, httplib, httplib2, aiohttpservice
Python PUT service request
Python (Flask, aiohttp) Web Service Put OperationService PUT operation

Python Delete Urllib, Httplib, Httplib2, aiohttp ServicePython Flask, aiohttp Web Service Delete OperationDELETE (urllib, urllib2, httplib, httplib2, aiohttpservice
Python DELETE service request
Python Flask, aiohttp Web Service DELETE operation

Python Query, Python ORM Mapping, Python File Query

RabbitMQ Python QueueCall
ActiveMQ Python QueueCall
IBM MQ Python QueueCall

RabbitMQ Python QueueReceive
ActiveMQ Python QueueReceive
IBM MQ Python QueueReceive

Python Call To Java Program

Python Call To Generic Program
Amazon Web Services

Python Call to AWS Lambda Function

Python AWS Lambda GET Operation

Python AWS Lambda POST Operation
Python AWS Lambda PUT Operation
Python AWS Lambda DELETE Operation

Python AWS Lambda ANY Operation

Python AWS SQS Publisher, Python AWS SNS Publisher

Python AWS SQS Receiver, Python AWS SNS Receiver

Python AWS SQS Unknown Publisher, Python AWS SNS Unknown Publisher

Python AWS SQS Unknown Receiver, Python AWS SNS Unknown Receiver

Image AddedImage AddedImage Added

Python Email, Python SMS

Python callable artifact

Python Script, Python Module and Python Method objects form part of Python (callable) artifacts.

...

The following structural rules are provided:

You can also find a global list here: https://technologies.castsoftware.com/rules?sec=t_1021000&ref=||

...

Code Block
languagepy
from flask.views import MethodView

class InformationAPI(MethodView):

    def get(self):
        information = Information.from_data(request.data)
        ...

app.add_url_rule('/<info>/informations/', view_func=InformationAPI.as_view('informations'))
  

falcon

Falcon routeroute annotations for web service operations (GET, PUT, POST, DELETE) are supported. 

In the following example, a default GET operation is ascribed to the functionon_get from GetResourceclass,and the POST and PUT operations to the on_putandon_postfunctions fromPut_PostResourcewith two differents urls routing:

The link between the GET operation named after the routing URL "/"  and the called functionon_get is represented by an arrow pointing to the function:

The name of a saved Web Service Operation object will be generated from the routing URL by adding a final slash when not present. In this example the name of the POST operations is "/url/example/1/" and  "/url/example/2/" after the routing url "/url/example/1" and "/url/example/2".

Sinks are supported with the following rules : If no route matches a request, but the path in the requested URI matches a sink prefix, Falcon will pass control to the associated sink, regardless of the HTTP method requested. If the prefix overlaps a registered route template, the route will take precedence and mask the sink.

In this case Web Service Operation objects generated as sinks will be named as/that/, and not as/this/since another Web Service Operation object exists with an overlapping url.

Code Block
languagepy
importfalcon
 
app=falcon.App()
 
class classGetResourceGetResource():
def defonon_get():
print('on_get function')
 
def defsinksink_method(resp,**kwargs):
resp.body="Sink"
pass
 
app.add_route('this/is/the/way', GetResource())
app.add_sink(sink_method, prefix='/that')#get # get, post, put & delete routes will be created and linked to sink_method
app.add_sink(sink_method, prefix='/this')#no # no routes created because Url overlaps another route

The optionnal suffixoptional suffix keyword argument of Falcon add_route is supported. In this way, multiple closely-related routes can be mapped to the same resource.

Code Block
languagepy
importfalconimport falcon
app=falcon.App()
 
classPrefixResourceclass PrefixResource(object):
 
def defonon_get(self, req, resp):
pass
 
def defonon_get_foo(self, req, resp):
pass
 
defondef on_post_foo(self, req, resp):
pass
 
def defonon_delete_bar(self, req, resp):
pass
 
app.add_route('get/without/prefix', PrefixResource())
app.add_route('get/and/post/prefix/foo', PrefixResource(), suffix='foo')
app.add_route('delete/prefix/bar', PrefixResource(), suffix='bar')

web2py

Example for GET request:

Code Block
languagepy
from gluon.tools import fetch
def m(self):
    page = fetch('http://www.google.com/')

Example link from method "m" to the get web2py service:


Generic service requests

Python GET/POST/PUT/DELETE service request objects will be used as generic objects for new supported frameworks implementing APIs to access web services.


Database access

PEP 249

Simple database queries consistent with the Python Database API Specification (PEP 249) are recognized. This allows to support a large number of important libraries interfacing Python and SQL databases (SQLite, MySQL, etc). The analyzer identifies execute method calls as potential database queries and searches for generic SQL statements passed in as an argument ('SELECT ...", "INSERT ...)". In the example below data from the stocks table is retrieved via a SELECT statement passed explicitly by a string to the execute method of a cursor object.

...

The library boto3 is supported, the AWS SDK for python (with certain limitations). Configuration YAML files are also analyzed in search of serverless deployment frameworks. Support to Amazon Simple Notification Service (SNS) for Python in boto3 (Python SDK for Amazon Web Services) is available in Python versions ≥ 1.4.0-beta5. Configuration YAML files are also analyzed in search of serverless deployment frameworks.

Anchor
AWSLambda
AWSLambda
AWS Lambda in AWS deployment frameworks

...

Supported API methods (boto3)

Link TypeCallerCallee
  • botocore.client.SQS.send_message

  • botocore.client.SQS.send_message_batch
callLinkPython callable artifact

Python AWS SQS Publisher
Python AWS SQS Unknown Publisher

  • botocore.client.SQS.receive_message
callLink

Python AWS SQS Unknown Receiver
Python AWS SQS Receiver

Python callable artifact

AWS DynamoDB

...

Code samples

In this code, the module sqs_send_message.py publishes a message into the "SQS_QUEUE_URL" queue and in sqs_receive_message.py is received:

...

Note: when the name of the queue passed to the API method calls is resolvable (either because of unavailability or because of technical limitations), the analyzer will create Unknown Publisher and Receive objects.

Anchor
AWS-SNS
AWS-SNS
AWS SNS

There are two different APIs to manage SNS services, one based on a low-level client and the higher-level one based on resources.

Supported API methods (boto3)

Link TypeCallerCalleeRemarks

botocore.client.SNS.create_topic

N/AN/A

N/A

Determines the topic
botocore.client.SNS.publishcallLink

Python callable artifact

Python AWS SNS Publisher,
Python AWS SNS Unknown Publisher, Python SMS


botocore.client.SNS.publish_batchcallLinkPython callable artifactPython AWS SNS Publisher,
Python AWS SNS Unknown Publisher
botocore.client.SNS.subscribecallLink

Python AWS SNS Receiver,
Python AWS SNS Unknown Receiver

Python Call to AWS Lambda Function, 
Python AWS SQS Publisher, Python SMS, Python Email


boto3.resources.factory.sns.create_topicN/AN/AN/ADetermines the topic
boto3.resources.factory.sns.ServiceResource.TopicN/AN/AN/ADetermines the topic
boto3.resources.factory.sns.Topic.publishcallLinkPython callable artifact

Python AWS SNS Publisher,
Python AWS SNS Unknown Publisher, Python SMS


boto3.resources.factory.sns.Topic.subscribecallLink

Python AWS SNS Receiver,
Python AWS SNS Unknown Receiver

Python Call to AWS Lambda Function, 
Python AWS SQS Publisher, Python SMS, Python Email

boto3.resources.factory.sns.PlatformEndpoint.publishcallLinkPython callable artifact

Python AWS SNS Publisher,
Python AWS SNS Unknown Publisher, Python SMS



The supported protocols are the following:

protocol

object created

name of the object

emailPython AWS Emailan Email   (the email addresses are not evaluated)
http/httpsPython POST service requestthe url (evaluated from the endpoint)
lambdaPython Call to AWS Lambda Functionthe name of the lambda function (evaluated from the endpoint)
smsPython AWS SMSan SMS   (the SMS numbers are not evaluated)
sqsPython AWS Simple Queue Service Publisherthe name of the queue (evaluated from the endpoint)


The code example below shows a basic usage of the boto3 library and the results as seen in Enlighten after analysis of the code.

Code Block
languagepy
import boto3

client = boto3.client('sns', region_name='eu-west-3')
topicArn1 = client.create_topic( Name = "TOPIC1")['TopicArn']

def publish(topic):
    client.publish(TopicArn=topic, Message='<your message>')

def subscribe(topic):
    client.subscribe(TopicArn=topic, Protocol="email", Endpoint="lili@lala.com")
    client.subscribe(TopicArn=topic, Protocol="sms", Endpoint="123456789")
    client.subscribe(TopicArn=topic, Protocol="sqs", Endpoint="arn:partition:service:region:account-id:queueName")
    client.subscribe(TopicArn=topic, Protocol="http", Endpoint="http://foourl")
    client.subscribe(TopicArn=topic, Protocol="lambda", Endpoint="fooarn:function:lambda_name:v2")
    
publish(topicArn1)
subscribe(topicArn1)


The callLink links between the Publisher and the respective Subscribers are created by the Web Services Linker extension during application level.

Image Added

Note that for each method a maximum of one subscriber per given topic will be created as shown in the image above. In the absence of a well-resolved topic, the analyzer will create Unknown Publishers and Subscribers. There is no link created between unknown objects.


We can also have direct sms deliveries from calls to publish API methods:

Code Block
languagepy
import boto3
AWS_REGION = "us-east-1"

def send_sms_from_resource():
    sns = boto3.resource("sns", region_name=AWS_REGION)
    platform_endpoint = sns.PlatformEndpoint('endpointArn')
    platform_endpoint.publish(PhoneNumber='123456789')

def send_sms():
    conn = boto3.client("sns", region_name=AWS_REGION)
    conn.publish(PhoneNumber='123456789')

where the corresponding objects and links are:

Image Added

AWS DynamoDB

See DynamoDB support for Python source code.

AWS S3

Supported API methods

Link TypeCallerCalleeOther effects

botocore.client.S3.create_bucket

N/AN/A

N/A

Creation of S3 bucket and S3 region objects

botocore.client.S3.put_object

useInsertLinkPython callable artifact

Python S3 Bucket, Python Unknown S3 Bucket


botocore.client.S3.delete_bucket

useDeleteLinkPython callable artifact

Python S3 Bucket. Python Unknown S3 Bucket




botocore.client.S3.delete_object


botocore.client.S3.delete_objects

botocore.client.S3.get_object

useSelectLinkPython callable artifact

Python S3 Bucket, Python Unknown S3 Bucket


botocore.client.S3.get_object_torrent


botocore.client.S3.list_objects


botocore.client.S3.list_objects_v2

botocore.client.S3.put_bucket_logging

useUpdateLinkPython callable artifactPython S3 Bucket, Python Unknown S3 Bucket
botocore.client.S3.put_bucket_analytics_configuration

...