Skip to content
This repository has been archived by the owner on Nov 16, 2022. It is now read-only.

lambda: Remove lib and update executable as base64 encoded #2195

Merged
merged 3 commits into from
Jul 9, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG_UNRELEASED.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,5 @@
### Helpers

### MISC

- (impv) [\#2195](https://github.com/bandprotocol/bandchain/pull/2195) Remove lib and update executable as base64 encoded.
Binary file removed lambda/oracle/exec/lib64/ld-linux-x86-64.so.2
Binary file not shown.
Binary file removed lambda/oracle/exec/lib64/libc.so.6
Binary file not shown.
Binary file removed lambda/oracle/exec/lib64/libcrypt.so.1
Binary file not shown.
Binary file removed lambda/oracle/exec/lib64/libcrypto.so.10
Binary file not shown.
Binary file removed lambda/oracle/exec/lib64/libdl.so.2
Binary file not shown.
Binary file removed lambda/oracle/exec/lib64/libfreebl3.so
Binary file not shown.
Binary file removed lambda/oracle/exec/lib64/libgcc_s.so.1
Binary file not shown.
Binary file removed lambda/oracle/exec/lib64/libkeyutils.so.1
Binary file not shown.
Binary file removed lambda/oracle/exec/lib64/liblber-2.4.so.2
Binary file not shown.
Binary file removed lambda/oracle/exec/lib64/libldap-2.4.so.2
Binary file not shown.
Binary file removed lambda/oracle/exec/lib64/libm.so.6
Binary file not shown.
Binary file removed lambda/oracle/exec/lib64/libncurses.so.5
Binary file not shown.
Binary file removed lambda/oracle/exec/lib64/libnspr4.so
Binary file not shown.
Binary file removed lambda/oracle/exec/lib64/libplc4.so
Binary file not shown.
Binary file removed lambda/oracle/exec/lib64/libplds4.so
Binary file not shown.
Binary file removed lambda/oracle/exec/lib64/libpthread.so.0
Binary file not shown.
Binary file removed lambda/oracle/exec/lib64/libreadline.so.6
Binary file not shown.
Binary file removed lambda/oracle/exec/lib64/libresolv.so.2
Binary file not shown.
Binary file removed lambda/oracle/exec/lib64/librt.so.1
Binary file not shown.
Binary file removed lambda/oracle/exec/lib64/libssl.so.10
Binary file not shown.
Binary file removed lambda/oracle/exec/lib64/libtinfo.so.5
Binary file not shown.
Binary file removed lambda/oracle/exec/lib64/libz.so.1
Binary file not shown.
Binary file removed lambda/oracle/exec/usr/bin/bc
Binary file not shown.
Binary file removed lambda/oracle/exec/usr/bin/curl
Binary file not shown.
Binary file removed lambda/oracle/exec/usr/bin/jq
Binary file not shown.
Binary file removed lambda/oracle/exec/usr/lib64/libcom_err.so.2
Binary file not shown.
Binary file removed lambda/oracle/exec/usr/lib64/libcurl.so.4
Binary file not shown.
Binary file removed lambda/oracle/exec/usr/lib64/libgssapi_krb5.so.2
Binary file not shown.
Binary file removed lambda/oracle/exec/usr/lib64/libicudata.so.50
Binary file not shown.
Binary file removed lambda/oracle/exec/usr/lib64/libicuuc.so.50
Binary file not shown.
Binary file removed lambda/oracle/exec/usr/lib64/libidn2.so.0
Binary file not shown.
Binary file removed lambda/oracle/exec/usr/lib64/libjq.so.1
Binary file not shown.
Binary file removed lambda/oracle/exec/usr/lib64/libk5crypto.so.3
Binary file not shown.
Binary file removed lambda/oracle/exec/usr/lib64/libkrb5.so.3
Binary file not shown.
Binary file removed lambda/oracle/exec/usr/lib64/libkrb5support.so.0
Binary file not shown.
Binary file removed lambda/oracle/exec/usr/lib64/libnghttp2.so.14
Binary file not shown.
Binary file removed lambda/oracle/exec/usr/lib64/libnss3.so
Binary file not shown.
Binary file removed lambda/oracle/exec/usr/lib64/libnssutil3.so
Binary file not shown.
Binary file removed lambda/oracle/exec/usr/lib64/libonig.so.2
Binary file not shown.
Binary file removed lambda/oracle/exec/usr/lib64/libpsl.so.0
Binary file not shown.
Binary file removed lambda/oracle/exec/usr/lib64/libsasl2.so.2
Binary file not shown.
Binary file removed lambda/oracle/exec/usr/lib64/libselinux.so.1
Binary file not shown.
Binary file removed lambda/oracle/exec/usr/lib64/libsmime3.so
Binary file not shown.
Binary file removed lambda/oracle/exec/usr/lib64/libssh2.so.1
Binary file not shown.
Binary file removed lambda/oracle/exec/usr/lib64/libssl3.so
Binary file not shown.
Binary file removed lambda/oracle/exec/usr/lib64/libstdc++.so.6
Binary file not shown.
Binary file removed lambda/oracle/exec/usr/lib64/libunistring.so.0
Binary file not shown.
15 changes: 3 additions & 12 deletions lambda/oracle/run.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
import os
import shlex
import base64
import subprocess

HEADERS = {
Expand Down Expand Up @@ -35,22 +36,12 @@ def lambda_handler(event, context):

path = "/tmp/execute.sh"
with open(path, "w") as f:
f.write(body["executable"])
f.write(base64.b64decode(body["executable"]).decode())

os.chmod(path, 0o775)
try:
env = os.environ.copy()
env["PATH"] = env["PATH"] + ":" + os.path.join(os.getcwd(), "exec", "usr", "bin")
env["LD_LIBRARY_PATH"] = (
env["LD_LIBRARY_PATH"]
+ ":"
+ os.path.join(os.getcwd(), "exec", "lib64")
+ ":"
+ os.path.join(os.getcwd(), "exec", "usr", "lib64")
)

result = subprocess.run(
[path] + shlex.split(body["calldata"]), env=env, timeout=3, capture_output=True
[path] + shlex.split(body["calldata"]), timeout=3, capture_output=True
)

return {
Expand Down