...
Icon | Description |
---|---|
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 Post Urllib, Urllib2, Httplib, Httplib2, aiohttp ServicePython POST (urllib, urllib2, httplib, httplib2, aiohttp) service | |
Python Put Urllib, Httplib, Httplib2, aiohttp ServicePython PUT (urllib, urllib2, httplib, httplib2, aiohttp) service | |
Python Delete Urllib, Httplib, Httplib2, aiohttp ServicePython Flask, aiohttp Web Service Delete OperationDELETE (urllib, urllib2, httplib, httplib2, aiohttp) service | |
Python Query, Python ORM Mapping, Python File Query | |
RabbitMQ Python QueueCall | |
RabbitMQ 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 | |
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 | ||
---|---|---|
| ||
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 | ||
---|---|---|
| ||
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 | ||
---|---|---|
| ||
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 | ||
---|---|---|
| ||
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 | ||||
---|---|---|---|---|
|
...
Supported API methods (boto3) | Link Type | Caller | Callee |
---|---|---|---|
| callLink | Python callable artifact | Python AWS SQS Publisher |
| callLink | Python AWS SQS Unknown 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 | ||||
---|---|---|---|---|
|
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 Type | Caller | Callee | Remarks |
---|---|---|---|---|
botocore.client.SNS.create_topic | N/A | N/A | N/A | Determines the topic |
botocore.client.SNS.publish | callLink | Python callable artifact | Python AWS SNS Publisher, | |
botocore.client.SNS.publish_batch | callLink | Python callable artifact | Python AWS SNS Publisher, Python AWS SNS Unknown Publisher | |
botocore.client.SNS.subscribe | callLink | Python AWS SNS Receiver, | Python Call to AWS Lambda Function, | |
boto3.resources.factory.sns.create_topic | N/A | N/A | N/A | Determines the topic |
boto3.resources.factory.sns.ServiceResource.Topic | N/A | N/A | N/A | Determines the topic |
boto3.resources.factory.sns.Topic.publish | callLink | Python callable artifact | Python AWS SNS Publisher, | |
boto3.resources.factory.sns.Topic.subscribe | callLink | Python AWS SNS Receiver, | Python Call to AWS Lambda Function, Python AWS SQS Publisher, Python SMS, Python Email | |
boto3.resources.factory.sns.PlatformEndpoint.publish | callLink | Python callable artifact | Python AWS SNS Publisher, |
The supported protocols are the following:
protocol | object created | name of the object |
---|---|---|
Python AWS Email | an Email (the email addresses are not evaluated) | |
http/https | Python POST service request | the url (evaluated from the endpoint) |
lambda | Python Call to AWS Lambda Function | the name of the lambda function (evaluated from the endpoint) |
sms | Python AWS SMS | an SMS (the SMS numbers are not evaluated) |
sqs | Python AWS Simple Queue Service Publisher | the 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 | ||
---|---|---|
| ||
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.
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 | ||
---|---|---|
| ||
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:
AWS DynamoDB
See DynamoDB support for Python source code.
AWS S3
Supported API methods | Link Type | Caller | Callee | Other effects |
---|---|---|---|---|
botocore.client.S3.create_bucket | N/A | N/A | N/A | Creation of S3 bucket and S3 region objects |
botocore.client.S3.put_object | useInsertLink | Python callable artifact | Python S3 Bucket, Python Unknown S3 Bucket | |
botocore.client.S3.delete_bucket | useDeleteLink | Python callable artifact | Python S3 Bucket. Python Unknown S3 Bucket | |
botocore.client.S3.delete_object | ||||
botocore.client.S3.delete_objects | ||||
botocore.client.S3.get_object | useSelectLink | Python 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 | useUpdateLink | Python callable artifact | Python S3 Bucket, Python Unknown S3 Bucket | |
botocore.client.S3.put_bucket_analytics_configuration |
...