Git Product home page Git Product logo

Comments (11)

mhart avatar mhart commented on June 16, 2024

The reason is to reduce size – but I don't think it does what you think it does.

Near I can tell, GitPython (which truffleHog uses) just requires the git binary: https://github.com/gitpython-developers/GitPython#requirements – which this layer has.

Give it a shot!

from git-lambda-layer.

mhart avatar mhart commented on June 16, 2024

Going to close this – if you actually get an error trying to call git from Python, feel free to post it here

from git-lambda-layer.

LewisLebentz avatar LewisLebentz commented on June 16, 2024

Hi @mhart sorry I'm new to Layers, trying to understand how they work still!

Tried using the layer earlier, and without it, it runs - just failing at the part where it tries to use git. When I add the layer all I get is "Unable to import module 'handler'".

No idea how to troubleshoot it, if I remove the layer it runs 🤷‍♂️. Does the handler need to change when using a Layer?

from git-lambda-layer.

mhart avatar mhart commented on June 16, 2024

Nope, shouldn't need to change at all. Might be that some sort of error is happening during the import process?

You could try using docker-lambda to replicate the error locally to help with debugging it.

Otherwise, sounds like you might just need to triage a little more.

from git-lambda-layer.

mhart avatar mhart commented on June 16, 2024

Also, if you post a small reproduction, I can try to triage myself and see what's up

from git-lambda-layer.

LewisLebentz avatar LewisLebentz commented on June 16, 2024

There isn't much to it right now, still just trying to get the basics working before developing it.

GitHub sends details of a commit to API Gateway, which goes to my Lambda and runs this:

import json
from truffleHog import truffleHog

def handler(event, context):
    try:
        print("EVENT:")
        print(event)
        print("CONTEXT:")
        print(context)
        print("BODY:")
        print(event['body'])
        githubData = json.loads(event['body'])
        print("COMMIT:")
        print(githubData['before'])
        print("URL:")
        print(githubData['repository']['url'])
        print("truffleHog:")
        print(truffleHog.find_strings(githubData['repository']['url'], do_regex=True, do_entropy=True, max_depth=100000, since_commit=githubData['before'], printJson=True, surpress_output=False))
        #print(truffleHog.find_strings(githubData['repository']['url'], do_regex=True, do_entropy=True, max_depth=100000))
        response = {
            "statusCode": 200,
            "body": "test",
        }
        return(response)
    except Exception as error:
        traceback.print_exc()

I'll keep trying to learn how Layers work to see if I can figure it out myself, but only started looking at them for the first time this morning. Could be something obvious that I've missed but just seems strange that it does work without the layer.

from git-lambda-layer.

mhart avatar mhart commented on June 16, 2024

I get:

{
  "errorType": "NameError",
  "errorMessage": "name 'traceback' is not defined",
  "stackTrace": [
    "  File \"/var/task/handler.py\", line 26, in handler\n    traceback.print_exc()\n"
  ]
}

from git-lambda-layer.

mhart avatar mhart commented on June 16, 2024

If I import traceback it seems to import fine

from git-lambda-layer.

LewisLebentz avatar LewisLebentz commented on June 16, 2024

Hmm ok, must be something wrong with my setup then! I'll try deleting and redeploying the Lambda and dependencies when I'm back on my work laptop tomorrow.

Apologies! Thanks for your help.

from git-lambda-layer.

mhart avatar mhart commented on June 16, 2024

No probs – to clarify, I got it running fine under docker-lambda – which is a pretty good proxy of the live Lambda environment. But there's still a chance that there's some permission or something on Lambda that might get in the way. I wouldn't have expected it to crash at the import stage though.

from git-lambda-layer.

LewisLebentz avatar LewisLebentz commented on June 16, 2024

Thanks, just thought I'd confirm - it does work with Python.

Redeployed a fresh version of my Lambda and it worked!

from git-lambda-layer.

Related Issues (20)

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.