Skip to content

Commit

Permalink
Merge pull request #14 from lemenkov/security
Browse files Browse the repository at this point in the history
Security
  • Loading branch information
lemenkov authored Apr 19, 2024
2 parents ea955ae + 3891e77 commit f7e1880
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 47 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/automatic_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: Release
uses: softprops/action-gh-release@v2
uses: svenstaro/upload-release-action@v2
88 changes: 43 additions & 45 deletions erlang-find-provides.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
# information that needs to be included in the package.

import getopt
import glob
import pybeam
import re
import sys
Expand Down Expand Up @@ -164,50 +163,49 @@
appmask = re.compile(".*/ebin/.*\.app")
# There should be only one app-file or none
for appfile in sorted([p for p in rawcontent if appmask.match(p)]):
f = open(appfile, 'r')
appcontents = f.read()
f.close()
# module erlang-erts (Erlang VM)
if appcontents.split(",")[1].lstrip().rstrip() == "erts":
# Export DRV version
f = open("%s/erts/emulator/beam/erl_driver.h" % BUILDDIR, 'r')
ERL_DRV_EXTENDED_MAJOR_VERSION = None
ERL_DRV_EXTENDED_MINOR_VERSION = None
for line in f:
ms = re.search("(?<=^#define\sERL_DRV_EXTENDED_MAJOR_VERSION\s)[0-9]+(?=$)", line)
if ms:
ERL_DRV_EXTENDED_MAJOR_VERSION = ms.group(0)
for line in f:
ms = re.search("(?<=^#define\sERL_DRV_EXTENDED_MINOR_VERSION\s)[0-9]+(?=$)", line)
if ms:
ERL_DRV_EXTENDED_MINOR_VERSION = ms.group(0)
# FIXME die here if ERL_DRV_EXTENDED_MAJOR_VERSION or ERL_DRV_EXTENDED_MINOR_VERSION is None
Provides += "erlang(erl_drv_version) = %s.%s" % (ERL_DRV_EXTENDED_MAJOR_VERSION, ERL_DRV_EXTENDED_MINOR_VERSION)
f.close()

# Export NIF version
f = open("%s/erts/emulator/beam/erl_nif.h" % BUILDDIR, 'r')
ERL_NIF_MAJOR_VERSION = None
ERL_NIF_MINOR_VERSION = None
for line in f:
ms = re.search("(?<=^#define\sERL_NIF_MAJOR_VERSION\s)[0-9]+(?=$)", line)
if ms:
ERL_NIF_MAJOR_VERSION = ms.group(0)
for line in f:
ms = re.search("(?<=^#define\sERL_NIF_MINOR_VERSION\s)[0-9]+(?=$)", line)
if ms:
ERL_NIF_MINOR_VERSION = ms.group(0)
# FIXME die here if ERL_NIF_MAJOR_VERSION or ERL_NIF_MINOR_VERSION is None
Provides += "erlang(erl_drv_version) = %s.%s" % (ERL_NIF_MAJOR_VERSION, ERL_NIF_MINOR_VERSION)
f.close()

# Add BIFs for erlang:F/A
Provides += ErtsBIFProvides

# module erlang-hipe
if appcontents.split(",")[1].lstrip().rstrip() == "hipe":
# Add BIFs for hipe_bifs:F/A
Provides += HipeBIFprovides
with open(appfile, 'r') as f0:
appcontents = f0.read()

# module erlang-erts (Erlang VM)
if appcontents.split(",")[1].lstrip().rstrip() == "erts":

# Export DRV version
with open("%s/erts/emulator/beam/erl_driver.h" % BUILDDIR, 'r') as f:
ERL_DRV_EXTENDED_MAJOR_VERSION = None
ERL_DRV_EXTENDED_MINOR_VERSION = None
for line in f:
ms = re.search("(?<=^#define\sERL_DRV_EXTENDED_MAJOR_VERSION\s)[0-9]+(?=$)", line)
if ms:
ERL_DRV_EXTENDED_MAJOR_VERSION = ms.group(0)
for line in f:
ms = re.search("(?<=^#define\sERL_DRV_EXTENDED_MINOR_VERSION\s)[0-9]+(?=$)", line)
if ms:
ERL_DRV_EXTENDED_MINOR_VERSION = ms.group(0)
# FIXME die here if ERL_DRV_EXTENDED_MAJOR_VERSION or ERL_DRV_EXTENDED_MINOR_VERSION is None
Provides += "erlang(erl_drv_version) = %s.%s" % (ERL_DRV_EXTENDED_MAJOR_VERSION, ERL_DRV_EXTENDED_MINOR_VERSION)

# Export NIF version
with open("%s/erts/emulator/beam/erl_nif.h" % BUILDDIR, 'r') as f:
ERL_NIF_MAJOR_VERSION = None
ERL_NIF_MINOR_VERSION = None
for line in f:
ms = re.search("(?<=^#define\sERL_NIF_MAJOR_VERSION\s)[0-9]+(?=$)", line)
if ms:
ERL_NIF_MAJOR_VERSION = ms.group(0)
for line in f:
ms = re.search("(?<=^#define\sERL_NIF_MINOR_VERSION\s)[0-9]+(?=$)", line)
if ms:
ERL_NIF_MINOR_VERSION = ms.group(0)
# FIXME die here if ERL_NIF_MAJOR_VERSION or ERL_NIF_MINOR_VERSION is None
Provides += "erlang(erl_drv_version) = %s.%s" % (ERL_NIF_MAJOR_VERSION, ERL_NIF_MINOR_VERSION)

# Add BIFs for erlang:F/A
Provides += ErtsBIFProvides

# module erlang-hipe
if appcontents.split(",")[1].lstrip().rstrip() == "hipe":
# Add BIFs for hipe_bifs:F/A
Provides += HipeBIFprovides

# Iterate over all BEAM-files
beammask = re.compile(".*/ebin/.*\.beam")
Expand Down
1 change: 0 additions & 1 deletion erlang-find-requires.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,6 @@ def inspect_beam_file(ISA, filename):
#exit(1)

BeamModRequires = sort_and_uniq(Dict.keys())
print(BeamModRequires)

# let's find RPM-packets to which these modules belongs
# We return more than one match since there could be situations where the same
Expand Down

0 comments on commit f7e1880

Please sign in to comment.