Git Product home page Git Product logo

node-lambda-inspector's Introduction

node-lambda-inspector

Webtask.io setup

Overview

This profiler will also work with Auth0's webtask.io. Webtask expects a single Javascript file to be provided. We can work around this by utilizing another Auth0 project, webtask-bundle.

Setup

You can install webtask-bundle with npm:

$ npm i -g webtask-bundle

Usage

Assuming you are in the root of this repository, you can run:

$ wt-bundle --output ./webtask-profiler.js ./webtask.js
Bundle successfully written to `./webtask-profiler.js`
$ wt create webtask-profiler.js
Webtask created

You can access your webtask at the following url:

https://wt-0ad02e9d22fed48c956fa4d6b11a93d3-0.run.webtask.io/webtask-profiler

node-lambda-inspector's People

Contributors

andrewkrug avatar danielhartnell avatar tnem avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

casualuser

node-lambda-inspector's Issues

Test webtask.io support

Webtask has some unique things regarding their execution envionment. Let's double check that we don't need to do something crazy like mash it into a single file.

Webtask is free to try. I did their hello world and got back... Just by running a one liner. But could not get two files to run.

https://wt-decac903c5c2d6bfe4e6f2927fd436b3-0.run.webtask.io/hello

{"PATH":"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin","HOSTNAME":"98ba9fa69a96","USER_ID":"30039","CLUSTER_SIZE":"1","PORT":"/data/io/port.sock","BACKCHANNEL_PORT":"/data/backchannel.sock","OS_LIMITS":"nproc=100:100,nofile=2048:2048","SANDBOX_STATS_HEADER":"1","EDGE_CS_CACHE":"1","EDGE_CS_TEMP_DIR":"/data/io","TRIPWIRE_TIMEOUT_MS":"2000","COOLDOWN_TIMEOUT":"1000","MAX_CODE_SIZE":"100","GET_CODE_TIMEOUT":"10000","MAX_CODE_CACHE_COUNT":"10","VERQUIRE_DIR":"/data/_verquire","NPM_CONFIG_LOGLEVEL":"info","NODE_VERSION":"4.4.5","HOME":"/root","NODE_ENV":"webtask"}

I got the error when trying to load both files.
{
"code": 400,
"message": "Invalid webtask code",
"error": "Supplied code must return or export a function."
}

Log timedata

Each run should also log a date time in epoch as part of the json

Lambdas and internet access

See python-lambda-inspector Issue #10

------------------------------------------ Also opened in node because it will need a solution as well.

Turns out lambda functions don't get any access to the internet without the presence of a cost prohibitive NAT gateway. This means that lambda functions running inside of the ThreatResponse AWS account will need to POST their results in a different way than runtimes out in the wild.

Potential options are:

  1. Profiler writes a {uuid.hex()}.json.gz file directly to S3 the same way the API does
  2. Profiler writes to dynamo and we pick that up somewhere else ( seems unnecessary )
  3. Deploy NAT gateway. ( Not cost effective ).
  4. Deploy the Lambda in the same VPC as the API box and point it directly at the API instead.

So I'm sure that you've gathered option 1 is preferred. It's just a matter of writing a little logic that only does the S3 upload if you're running from within a lambda function. We'll still need the urllib2.Request method in the python profiler that @jeffbryner wrote. Oddly it doesn't actually cause the function to fail. Simply nothing ever happens...

Option 4. isn't a bad choice either but has implications for if / when we want to go multi-region and puts heavier requirements on the CI/CD pipeline to attach things.

Replicate functionality present in python lambda inspector

  • /proc/meminfo to dictionary
  • /proc/cpuinfo to dictionary
  • contents of /etc/issue
  • sandbox variable ( this detects which runtime we're in )
  • package_count count of the list of loaded modules
  • platform
  • warmness fields, is_warm, warm_for

POST to API endpoint not working correctly

Think it's due to bad JSON.

Currently, posting even very simple JSON structures like: '{"pwd":"/Users/themnem/Code/lambda-env/node-lambda-inspector\\n"}' will work sometimes but not other times.

Last night the POST that completed successfully happened after I commented out everything in the lookups dictionary and only used pwd. Next step could be uncommenting them one by one and seeing what starts returning 400s. Unfortunately, after getting one 400 I was unable to recreate the original 200. Is it possible that the server can get put in a bad state after receiving JSON it doesn't like?

Current work for further testing is in branch upload-to-post

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.