UNCLASSIFIED

You need to sign in or sign up before continuing.
Commit 75191314 authored by David Freeman's avatar David Freeman
Browse files

run linters

parent e3d9fd1e
[*.sh]
indent_style = space
indent_size = 2
switch_case_indent = true # like -ci
\ No newline at end of file
# ironbank-plugins-pipeline
[pylama:pycodestyle]
max_line_length = 88
ignore = E203,E231,W503,E501
[pylama:pylint]
max_line_length = 88
......@@ -223,6 +223,13 @@
"uniqueItems": true
}
},
"required": ["apiVersion", "plugin-name", "version", "keywords", "resources", "maintainers"],
"required": [
"apiVersion",
"plugin-name",
"version",
"keywords",
"resources",
"maintainers"
],
"additionalProperties": false
}
......@@ -48,4 +48,4 @@ buildah push --storage-driver=vfs --authfile plugins_auth.json "${harbor_plugin_
echo "IMAGE_ID=sha256:$(podman inspect --storage-driver=vfs "${harbor_plugin_path}" --format '{{.Id}}')" >>"${ARTIFACT_DIR}/build.env"
echo "IMAGE_FULLTAG=${harbor_plugin_path}" >>"${ARTIFACT_DIR}/build.env"
\ No newline at end of file
echo "IMAGE_FULLTAG=${harbor_plugin_path}" >>"${ARTIFACT_DIR}/build.env"
......@@ -3,4 +3,4 @@
tags:
- ironbank-plugins
include:
- local: /stages/publish/upload_to_s3.yaml
\ No newline at end of file
- local: /stages/publish/upload_to_s3.yaml
......@@ -34,14 +34,14 @@ def main():
)
parser.add_argument("--binary-content", help="binary.json file path")
parser.add_argument("--files-content", help="files.json file path")
parser.add_argument("--gem-content", help="gem.json file path"")
parser.add_argument("--go-content", help="go.json file path"")
parser.add_argument("--java-content", help="java.json file path"")
parser.add_argument("--malware-content", help="malware.json file path"")
parser.add_argument("--npm-content", help="npm.json file path"")
parser.add_argument("--nuget-content", help="nuget.json file path"")
parser.add_argument("--os-content", help="os.json file path"")
parser.add_argument("--python-content", help="python.json file path"")
parser.add_argument("--gem-content", help="gem.json file path")
parser.add_argument("--go-content", help="go.json file path")
parser.add_argument("--java-content", help="java.json file path")
parser.add_argument("--malware-content", help="malware.json file path")
parser.add_argument("--npm-content", help="npm.json file path")
parser.add_argument("--nuget-content", help="nuget.json file path")
parser.add_argument("--os-content", help="os.json file path")
parser.add_argument("--python-content", help="python.json file path")
parser.add_argument(
"-o",
"--output-dir",
......@@ -170,12 +170,9 @@ def get_anchore_full(anchore_file):
cves.append(ret)
return cves
def create_content_csvs():
content_filenames = [
args.binary,
args.files,
args.gem
]
content_filenames = [args.binary, args.files, args.gem]
for report in content_filenames:
report_content = read_content_csv(report)
......@@ -183,12 +180,14 @@ def create_content_csvs():
return
def read_content_csv(filepath):
file = pathlib.Path(filepath)
with file.open(mode="r") as f:
data = json.load(f)
return data
def write_content_csv(report_data):
fields = list(report_data["content"][0].keys())
output_file_name = pathlib.Path(f"{report_data['content_type']}.csv")
......@@ -197,6 +196,7 @@ def write_content_csv(report_data):
writer.writeheader()
writer.writerows(report_data["content"])
class AnchoreGate:
image_id = ""
repo_tag = ""
......
......@@ -75,7 +75,6 @@ class Anchore:
return None
def get_version(self, artifacts_path):
"""
Fetch the Anchore version and write it to an artifact.
......@@ -130,7 +129,7 @@ class Anchore:
filename = pathlib.Path(artifacts_path, "anchore_security.json")
logging.debug(f"Writing to {filename}")
with filename.open(mode="w") as f:
json.dump(vuln_dict, f)
json.dump(vuln_dict, f)
def image_contents(self, digest, artifacts_path):
logging.info(f"Retrieving image contents")
......@@ -147,7 +146,7 @@ class Anchore:
"content",
digest,
]
try:
logging.debug(" ".join(contents_cmd))
image_contents = subprocess.run(
......@@ -161,7 +160,7 @@ class Anchore:
sys.exit(1)
logging.debug(image_contents.stdout)
content_types=json.loads(image_contents.stdout)
content_types = json.loads(image_contents.stdout)
for item in content_types:
contents_cmd = [
"anchore-cli",
......@@ -190,9 +189,8 @@ class Anchore:
logging.exception("Could not retrieve contents")
sys.exit(1)
returned_contents = json.loads(image_contents.stdout)
filename = pathlib.Path(artifacts_path, f"{item}.json")
with filename.open(mode="w") as f:
json.dump(returned_contents, f)
......
......@@ -7,6 +7,7 @@ import pathlib
from anchore import Anchore
def main():
# Get logging level, set manually when running pipeline
loglevel = os.environ.get("LOGLEVEL", "INFO").upper()
......@@ -39,5 +40,6 @@ def main():
anchore_scan.image_contents(digest=digest, artifacts_path=artifacts_path)
anchore_scan.get_version(artifacts_path=artifacts_path)
if __name__ == "__main__":
sys.exit(main())
......@@ -7,7 +7,7 @@ stages:
- preprocess
### preflight stage
# check for README and plugins_manifest.yaml
# check for README and plugins_manifest.yaml
# Requirements:
# - None
- preflight
......@@ -46,6 +46,3 @@ variables:
GIT_SSL_NO_VERIFY: "1"
TARGET_BRANCH: master
BUILD_FROM_SOURCE: ""
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment