Giter VIP home page Giter VIP logo

aws-lambda-snapstart-java-rules's Introduction

AWS Lambda SnapStart Bug Scanner

SnapStart Bug Scanner is the SpotBugs plugin for helping AWS Lambda customers inspect their functions against potential bugs unique to AWS Lambda SnapStart environment.

How to use

Following sections explain how to enable this plugin in your Gradle and Maven projects.

Gradle Builds

After SpotBugs is enabled in the Gradle project declaring a dependency on SnapStart bug scanner is sufficient.

Example:

plugins {
    id("com.github.spotbugs") version "4.7.3"
}

spotbugs {
    ignoreFailures.set(false)
    showStackTraces.set(true)
}

dependencies {
    spotbugs("com.github.spotbugs:spotbugs:4.7.3")
    spotbugsPlugins("software.amazon.lambda.snapstart:aws-lambda-snapstart-java-rules:0.2.1")
}

After updating the build.gradle file you can run ./gradlew check to run the analysis and see the result.

Maven Builds

After SpotBugs is enabled in the Maven project declaring a dependency on SnapStart bug scanner is sufficient.

Example:

<build>
    <plugins>
        <plugin>
            <groupId>com.github.spotbugs</groupId>
            <artifactId>spotbugs-maven-plugin</artifactId>
            <version>4.7.3.0</version>
            <configuration>
                <effort>Max</effort>
                <threshold>medium</threshold>
                <failOnError>true</failOnError>
                <plugins>
                    <plugin>
                        <groupId>software.amazon.lambda.snapstart</groupId>
                        <artifactId>aws-lambda-snapstart-java-rules</artifactId>
                        <version>0.2.1</version>
                    </plugin>
                </plugins>
            </configuration>
        </plugin>
    </plugins>
</build>

After updating pom.xml you can run mvn compile && mvn spotbugs:spotbugs to run the analysis and see results in targets/spotbugsXml.xml file. Also, you can run mvn spotbugs:check to see results on your terminal and mvn spotbugs:gui on SpotBug's graphical UI.

Bug Descriptions

SNAP_START: Detected handler state that is potentially not resilient to VM snapshot and restore operations. (AWS_LAMBDA_SNAP_START_BUG)

Our analysis shows that AWS Lambda handler class initialization creates state that may not remain unique for the function when it uses SnapStart. Lambda functions that use SnapStart are snapshotted at their initialized state and all execution environments created afterwards share the same initial state. This means that if the Lambda function relies on state that is not resilient to snapshot and restore operations, it might manifest an unexpected behavior by using SnapStart.

This tool helps provide an insight on possible cases where your code may not be fully compatible with snapstart enabled. Please verify that your code maintains uniqueness with SnapStart. For best practices, follow the guidelines outlined in SnapStart feature documentation. For more information on the tool and examples of scenarios that the tool helps identify, refer to the SnapStart scanner GitHub documentation.

Security

See CONTRIBUTING for more information.

License

This project is licensed under the Apache-2.0 License.

aws-lambda-snapstart-java-rules's People

Contributors

mbfreder avatar valerena avatar jfuss avatar halukyavuz avatar amazon-auto avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.