Page tree

Versions Compared

Key

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

...

Expand

In 1.3.x, MongoDB Connection and MongoDB Collection objects were added to Typescript Module objects and when a connection (or a collection) is accessed using Mongoose from several files, the analyzer was creating one connection (or collection) object per such file.
In versions >=1.4.x, MongoDB Connection and MongoDB Collection objects are added at the application level and when a connection (or a collection) is accessed using Mongoose from several files the analyzer creates only one connection (or collection).

In order to avoid "added objects" and minimize the number of "deleted objects" when updating from 1.3.x to >=1.4.x a migration is carried out. This migration requires com.castsoftware.internal.platform version >= 0.8.5 to be used.


Note that if the same connection (or collection) is accessed from different ts modules,  when analyzing with com.castsoftware.typescript 1.3.x several MongoDB Connection (or MongoDB Collection) objects are created whereas only one object is created with versions >=1.4.x. In such case, there would be "deleted objects" during the migration.

Anchor
AWSTypescript
AWSTypescript
More about AWS frameworks analysis

Anchor
AWSLambda
AWSLambda
AWS lambda

Expand

Behavior explanation

Serverless framework, Serverless Application Model (SAM), and Cloudformation are supported. These are frameworks using *.yml or *.json file to set up AWS environment. 
Whenever the runtime set in these files is nodejs, the com.castsoftware.nodejs extension is responsible for creating the corresponding NodeJS AWS Lambda Function, NodeJS AWS Lambda Operation (which represent AWS APIGateway events), and NodeJS AWS Simple Queue objects (see com.castsoftware.nodejs documentation for source codes and example). 

Warning

Since the com.castsoftware.nodejs extension is responsible for analyzing AWS deployment framework *.yml and *.json files the results of an analysis will depend on the version of com.castsoftware.nodjes used.


The typescript extension is responsible for linking these objects to the handler function whenever this handler function is a TypeScript function.

What results can you expect?

When analyzing the following source code with a recent enough version of com.castsoftware.nodejs ( 2.6.0.beta1):

Code Block
provider:
  name: aws
  runtime: nodejs12.x

functions:
  mylambda:
    handler: handler.apilambda
    events:
      - http:
          path: test
          method: get
      - sqs:
          arn:
            Fn::GetAtt:
              - MyQueue
              - Arn     	  
    environment:
      stage: ${opt:stage}
resources:
  Resources:
    MyQueue:
      Type: "AWS::SQS::Queue"
      Properties:
        QueueName: "MyQueue"

Assuming that the handler function is a TypeScript function, once the analysis/snapshot generation has completed, you can view the results in the normal manner (for example via CAST Enlighten):

Click to enlarge

Image Added


Anchor
AWSS3
AWSS3
AWS S3 framework analysis

Expand

Links

Link TypeFunction
No Link
  • createBucket
callLink
  • createMultipartUpload

  • createPresignedPost

  • abortMultipartUpload

  • completeMultipartUpload

  • deleteBucketAnalyticsConfiguration

  • deleteBucketCors

  • deleteBucketEncryption

  • deleteBucketInventoryConfiguration

  • deleteBucketLifecycle

  • deleteBucketMetricsConfiguration

  • deleteBucketPolicy

  • deleteBucketReplication

  • deleteBucketTagging

  • deleteBucketWebsite

  • deleteObjectTagging

  • deletePublicAccessBlock

  • getBucketAccelerateConfiguration

  • getBucketAcl

  • getBucketAnalyticsConfiguration

  • getBucketCors

  • getBucketEncryption

  • getBucketInventoryConfiguration

  • getBucketLifecycle

  • getBucketLifecycleConfiguration

  • getBucketLocation

  • getBucketLogging

  • getBucketMetricsConfiguration

  • getBucketNotification

  • getBucketNotificationConfiguration

  • getBucketPolicy

  • getBucketPolicyStatus

  • getBucketReplication

  • getBucketTagging

  • getBucketVersioning

  • getBucketWebsite

  • getObjectAcl

  • getObjectLegalHold

  • getObjectLockConfiguration

  • getObjectRetention

  • getObjectTagging

  • getPublicAccessBlock

  • getSignedUrl

  • listBuckets
  • listBucketAnalyticsConfigurations

  • listBucketInventoryConfigurations

  • listBucketMetricsConfigurations

  • listMultipartUploads

  • listObjectVersions

  • listParts

  • putBucketLogging
  • putBucketAnalyticsConfiguration
  • putBucketLifecycleConfiguration

  • putBucketMetricsConfiguration

  • putBucketNotification

  • putBucketNotificationConfiguration

  • putBucketPolicy

  • putBucketReplication

  • putBucketRequestPayment

  • putBucketTagging

  • putBucketVersioning

  • putObjectAcl

  • putObjectLegalHold

  • putObjectLockConfiguration

  • putObjectRetention

  • putObjectTagging

  • putPublicAccessBlock

  • putBucketAccelerateConfiguration

  • putBucketAcl

  • putBucketCors

  • putBucketEncryption

  • putBucketInventoryConfiguration

  • putBucketLifecycle

  • upload

  • uploadPart

  • uploadPartCopy

useInsertLink
  • putObject
useDeleteLink
  • deleteBucket
  • deleteObject

  • deleteObjects

useSelectLink
  • getObject
  • getObjectTorrent
  • listObjects

  • listObjectsV2

useUpdateLink
  • putBucketLogging
  • putBucketAnalyticsConfiguration

Code samples

This code will create a S3 Bucket named "MyBucket" on an AWS server in region "REGION" and puts an object in it

Code Block
languagejs
linenumberstrue
// Load the AWS SDK for Node.js
var AWS = require('aws-sdk');
// Set the region 
AWS.config.update({region: 'REGION'});

// Create S3 service object
s3 = new AWS.S3({apiVersion: '2006-03-01'});

// Create the parameters for calling createBucket
var bucketParams = {
  Bucket : "MyBucket",
  ACL : 'public-read'
};

// call S3 to create the bucket
s3.createBucket(bucketParams, function(err, data) {
  if (err) {
    console.log("Error", err);
  } else {
    console.log("Success", data.Location);
  }
});

params = {
	// ...
    Bucket: "MyBucket"
};
s3.putObject(params, function(err, data) {
    if (err) console.log(err, err.stack); // an error occurred
    else     console.log(data);           // successful response
});

What results can you expect?

Once the analysis/snapshot generation has completed, you can view the results in the normal manner (for example via CAST Enlighten):

Image Added

Analysis of the code sample




Anchor
SQSTypeScript
SQSTypeScript
AWS SQS framework analysis

Expand
Links
Link TypeFunction
callLink
  • sendMessage

  • sendMessageBatch
  • receiveMessage
Support for SDK

This code will publish a message into the "SQS_QUEUE_URL" queue:

Code Block
languagejs
linenumberstrue
import * as AWS from "aws-sdk";
AWS.config.update({ region: 'REGION' });

const sqs = new AWS.SQS({apiVersion: '2012-11-05'});

const queueUrl = "SQS_QUEUE_URL"

const params = {
	MessageBody: "This is a message",
    QueueUrl: queueUrl,
    MaxNumberOfMessages: 1,
    VisibilityTimeout: 0,
};


sqs.sendMessage(params, function (err, data) {
    if (err) {
        console.log("Error", err);
    } else {
        console.log("Success", data.MessageId);
    }
});
}

This code will receive a message from the queue "SQS_QUEUE_URL"

Code Block
languagejs
linenumberstrue
import * as AWS from "aws-sdk";
AWS.config.update({ region: 'REGION' });

const sqs = new AWS.SQS({apiVersion: '2012-11-05'});

const queueUrl = "SQS_QUEUE_URL"

const params = {
    QueueUrl: queueUrl,
    MaxNumberOfMessages: 1,
    VisibilityTimeout: 0,
};

export class SqsReciver {
    constructor() {
        this.reciver();
    }
    private reciver(): void {
        sqs.receiveMessage(params, (err, data) => {
	// do something
        });
    }
}
What results can you expect?

Once the analysis/snapshot generation has completed, you can view the results in the normal manner (for example via CAST Enlighten):

Click to enlarge

Image Added

When the evaluation of the queue name fails, a Node.js AWS SQS Unknown Publisher (or Receiver) will be created.

Known limitations for AWS support

  • The use of AWS.SQS with promises is not supported. For instance no link would be created between the receiver and the handler function defined in .then() call in the following source code: 

    Code Block
    languagexml
    this.sqs.receiveMessage(params).promise().then( () => {})


  • If the queueName is set using the createQueue api, the evaluation of the queue name will fail.

SQL Database Access

This extension supports some libraries offering access to SQL databases. The SQL frameworks analysis is based on the evaluation of the first argument of the "query()" and "execute()" method calls. The first argument is evaluated and if it corresponds to an SQL query, a CAST_TS_Query object is created. In the case where the first argument does not correspond to a SQL query, we evaluate the second argument if is exists. Text only and parameterized SQL queries are supported. This heuristic allows us to support a large number of SQL database frameworks.

...

Expand

In the following code: 

Code Block
var oracledb = require('oracledb');
 
oracledb.getConnection(
  {
    user          : "hr",
    password      : "welcome",
    connectString : "localhost/XE"
  },
  function doSelect(err, connection)
  {
    if (err) { console.error(err); return; }
    connection.execute(
      "SELECT department_id, department_name "
    + "FROM titles "
    + "WHERE department_id < 70 "
    + "ORDER BY department_id",
      function(err, result)
      {
        if (err) { console.error(err); return; }
        console.log(result.rows);
      });
  });
};

In this example, a TypeScript query object is created and a callLink between the anonymous function and that query is added. The sql analyzer can then link that query with the corresponding table if the table exists. In the present case, this extension creates a useSelect link to the table 'titles':

Links

Analysis of the TypeScript application will result in the following links:

...