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

Safer dependencies collector #24

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/metapackage.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class MetaPackage:

def __init__(self, pkgname, pkgtype=None, pkgorg=None):
self.instances.append(self) # adding the instance to colllective
if len(pkgname.split(':')) == 2:
if len(str(pkgname).split(':')) == 2:
if pkgtype == "maven":
if pkgorg == None:
self._pkg_name = pkgname.split(':')[1]
Expand Down
3 changes: 2 additions & 1 deletion src/registry/maven.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import json
import requests
import xml.etree.ElementTree as ET
Expand Down Expand Up @@ -35,7 +36,7 @@ def recv_pkg_info(pkgs, url=REGISTRY_URL):

def scan_source(dir):
try:
path = dir + "./pom.xml"
path = os.path.join(dir, "./pom.xml")
moshe-apiiro marked this conversation as resolved.
Show resolved Hide resolved
tree = ET.parse(path)
pom = tree.getroot()
ns = ".//{http://maven.apache.org/POM/4.0.0}"
Expand Down
18 changes: 9 additions & 9 deletions src/registry/npm.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import json
import requests
import sys
Expand All @@ -7,6 +8,7 @@
# deets: https://api-docs.npms.io/#api-Package-GetPackageInfo
REGISTRY_URL = "https://api.npms.io/v2/package/mget"


def get_keys(data):
result = []
for key in data.keys():
Expand Down Expand Up @@ -48,20 +50,18 @@ def recv_pkg_info(pkgs, url=REGISTRY_URL):
i.exists = False


def scan_source(dir):
def scan_source(dir_):
moshe-apiiro marked this conversation as resolved.
Show resolved Hide resolved
try:
path = dir + "./package.json"
file = open(path, "r")
body = file.read()
filex = json.loads(body)
with open(os.path.join(dir_, "package.json"), "r") as file:
filex = json.load(file)
except:
print("[ERR] Couldn't import from given path.")
sys.exit(1)

lister = list(filex['dependencies'].keys())
if 'devDependencies' in filex:
lister.append(filex['devDependencies'].keys())
# OPTIONAL - de-comment if you would like to add peer deps.
#lister.append(filex['peerDependencies'].keys())
lister += list(filex['devDependencies'].keys())
# OPTIONAL - de-comment if you would like to add peer deps.
# if 'peerDependencies' in filex:
# lister += list(filex['peerDependencies'].keys())
return lister