Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dates are empty in the json file if run in AWS Lambda #2512

Open
semeniuv opened this issue Jun 20, 2024 · 6 comments
Open

Dates are empty in the json file if run in AWS Lambda #2512

semeniuv opened this issue Jun 20, 2024 · 6 comments

Comments

@semeniuv
Copy link

semeniuv commented Jun 20, 2024

I am using version 3.2.
I've built a container-based AWS lambda to be able to run the scan via AWS SQS.
I use Python lambda to run the command.
When I run testssl.sh inside a container on my server it's all good, but when I ran tests on AWS the JSON file doesn't have any dates in it:

This how a normal file looks like:
Screenshot 2024-06-20 141730

This is how it looks when run via AWS lambda:
image

Can you help me in finding the solution?

@drwetter
Copy link
Owner

  • what is a "container-based AWS-lambda" : A full container or AWS lambda?
  • Is it only the certificate times, which are missing?

@semeniuv
Copy link
Author

So the docker image is built using public.ecr.aws/lambda/python:3.12-x86_64
I also pull the repo using RUN git clone --depth 1 https://github.com/drwetter/testssl.sh.git /opt/testssl.
If I run the lambda function that triggers the testssl.sh locally on the server where I build the image by invoking the lambda all works well, once I push the image to AWS and run tests there the cert dates are empty. So far I have noticed only these dates as they are crucial for my app. It looks like the issue might be related to the system locale.

@drwetter
Copy link
Owner

It's hard to tell remotely what's wrong here. Can you debug determine_dates_certificate() yourself ?

E.g. by editing the program and add there set -x`, run the section of the script, then later set +x``. And comparing it with a non-lambda thing?

@semeniuv
Copy link
Author

semeniuv commented Jun 25, 2024

I will try, thanks. But by the looks it can determine the dates as it calculates how many days are left until the cert is expired. My guess is it's just a date output issue not reading the certificate data. And one more thing, when I save the output to the file I can see the script start and end date but not cert dates.

@semeniuv
Copy link
Author

During testing, I replaced enddate in the determine_dates_certificate() function with a random string dates, and tied it running like that on AWS and the cert dates remained empty. So I can come to concluding it has nothing to do with dates, it is just an output. Can it be safe_echo() function?

@semeniuv
Copy link
Author

semeniuv commented Jun 26, 2024

It's hard to tell remotely what's wrong here. Can you debug determine_dates_certificate() yourself ?

E.g. by editing the program and add there set -x`, run the section of the script, then laterset +x``. And comparing it with a non-lambda thing?

This is what I get on AWS: INFO:root:STDERR: b'|8884> \tset +x\n/opt/testssl.sh/testssl.sh: line 9556: /dev/fd/62: No such file or directory\n/opt/testssl.sh/testssl.sh: line 9903: /dev/fd/62: No such file or directory\n'

It looks like this line: IFS=',' read -r startdate enddate diffseconds days2expire yearstart < <(determine_dates_certificate "${intermediate_certs_txt[i]}")

Can it be because in the lambda there is only one writeable directory and it's /tmp ?
Do you use any temp files?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants