Skip to content

Commit

Permalink
vuejs support (#123)
Browse files Browse the repository at this point in the history
  • Loading branch information
Prabhu Subramanian authored Jul 8, 2020
1 parent eeb4507 commit f8807c9
Show file tree
Hide file tree
Showing 9 changed files with 470 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
rm -rf AppDir appimage-builder-cache
rm *.AppImage*
mkdir -p appimage-builder-cache
cp ~/Downloads/runtime-x86_64 appimage-builder-cache/
wget https://github.com/AppImage/AppImageKit/releases/download/12/runtime-x86_64 -O appimage-builder-cache/runtime-x86_64
UPDATE_INFO="gh-releases-zsync|ShiftLeftSecurity|sast-scan|latest|*x86_64.AppImage.zsync" appimage-builder --recipe appimage-builder.yml --skip-test
rm -rf AppDir appimage-builder-cache
chmod +x *.AppImage
6 changes: 3 additions & 3 deletions lib/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ def auto_build(type_list, src, reports_dir):
return ret
# Look for any _scan function in this module for execution
try:
getattr(sys.modules[__name__], "%s_build" % ptype)(
src, reports_dir, lang_tools
)
dfn = getattr(sys.modules[__name__], "%s_build" % ptype, None)
if dfn:
dfn(src, reports_dir, lang_tools)
except Exception:
continue
return ret
Expand Down
7 changes: 6 additions & 1 deletion lib/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
"credscan",
"depscan",
"go",
"groovy",
"java",
"jsp",
"kotlin",
Expand All @@ -100,7 +101,6 @@
".mvn",
".idea",
"dist",
"bin",
"obj",
"backup",
"docs",
Expand All @@ -114,6 +114,9 @@
".serverless",
"venv",
".virtualenv",
"vendor",
"bower_components",
".vscode",
]

# Ignore files list
Expand All @@ -138,6 +141,8 @@
".d.ts",
".min.js",
".min.css",
".eslintrc.js",
".babelrc.js",
]


Expand Down
6 changes: 5 additions & 1 deletion lib/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def tweak_severity(tool_name, issue_dict):
:return:
"""
issue_severity = issue_dict["issue_severity"]
if tool_name in ["staticcheck", "psalm", "phpstan"]:
if tool_name in ["staticcheck", "psalm", "phpstan", "source-js"]:
if issue_severity in ["HIGH", "CRITICAL"]:
return "MEDIUM"
return "LOW"
Expand Down Expand Up @@ -188,7 +188,11 @@ def extract_from_file(
)
elif tool_name == "source-js":
njs_findings = report_data.get("nodejs", {})
njs_findings.update(report_data.get("templates", {}))
for k, v in njs_findings.items():
# Password detection by njsscan is full of false positives
if k == "node_password":
continue
files = v.get("files", [])
metadata = v.get("metadata", {})
if not files or not metadata:
Expand Down
2 changes: 1 addition & 1 deletion lib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def is_ignored_file(base_dir, file_name):
return False
file_name = file_name.lower()
extn = "".join(Path(file_name).suffixes)
if extn in config.ignore_files:
if extn in config.ignore_files or file_name in config.ignore_files:
return True
return False

Expand Down
7 changes: 4 additions & 3 deletions scan
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,7 @@ def scan(type_list, src, reports_dir, convert, scan_mode, repo_context):
else:
# Look for any _scan function in this module for execution
try:
dfn = getattr(
sys.modules[__name__], "%s_scan" % type_str, None
)
dfn = getattr(sys.modules[__name__], "%s_scan" % type_str, None)
if dfn:
pool.apply_async(
dfn, (src, reports_dir, convert, repo_context)
Expand Down Expand Up @@ -466,7 +464,10 @@ def sec_scan(src, reports_dir, convert, repo_context):
sec_cmd = "njsscan"
sec_args = [sec_cmd, *convert_args]
js_files = utils.find_files(src, ".js")
vue_files = utils.find_files(src, ".vue")
sec_args += js_files
if vue_files:
sec_args += vue_files
exec_tool("source-js", sec_args, src)
if convert:
crep_fname = utils.get_report_file(
Expand Down
Loading

0 comments on commit f8807c9

Please sign in to comment.