Skip to content

Commit e07e135

Browse files
committed
Fix Gemfile parsing code. Rely on 'bundle lock'
Signed-off-by: Ashish Bijlani <ashish.bijlani@gmail.com>
1 parent 432e8c5 commit e07e135

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

.packj.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#
2-
# PRO account (XXX activated ONLY when 'auth' subcommand is used. see '--help')
2+
# Pro account for premium features
3+
#
4+
# XXX use 'auth' subcommand to activate. See '--help' for details.)
35
#
46
account:
57
creds_file: ~/.packj.creds

Gemfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
source 'https://rubygems.org'
2+
ruby "2.5.1"
3+
4+
gem 'google-protobuf','3.21.2'
5+
gem 'rubocop','1.28.2'

packj/audit/main.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,6 @@ def parse_request_args(args):
751751
msg_info(f'Missing host volume at {container_mountpoint}. Run Docker/Podman with "-v /tmp:{container_mountpoint}" argument.')
752752
exit(1)
753753

754-
import inspect
755754
# build list of packages to audit
756755
audit_pkg_list = []
757756
for item in args.depfiles:

packj/audit/pm_proxy/rubygems.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,18 @@ def __parse_string_for_dep_info(self, line):
5252
def parse_deps_file(self, deps_file):
5353
try:
5454
cwd = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
55+
if not deps_file.endswith('.lock'):
56+
cmd = ['bundle', 'lock', '--lockfile=packj-generated-Gemfile.lock']
57+
stdout, stderr, error = exec_command("generate lockfile", cmd, cwd=cwd, redirect_mask=3)
58+
if error or not stdout:
59+
logging.debug(f'failed to generate lockfile for {deps_file}:\n{stdout}\n{stderr}')
60+
raise Exception(f'deps parse error {error}!')
61+
deps_file = dst = os.path.join(cwd, 'packj-generated-Gemfile.lock')
62+
5563
cmd = ['ruby', 'parse_gemfile.rb', os.path.abspath(deps_file)]
5664
stdout, stderr, error = exec_command("parse deps", cmd, cwd=cwd, redirect_mask=3)
5765
if error or not stdout:
58-
logging.debug(f'deps parse error:\n{stdout}\n{stderr}')
66+
logging.debug(f'failed to parse {deps_file}:\n{stdout}\n{stderr}')
5967
raise Exception(f'deps parse error {error}!')
6068

6169
dep_list = []

0 commit comments

Comments
 (0)