Skip to content

Commit

Permalink
feat: Updates to support use by addonfactory
Browse files Browse the repository at this point in the history
  • Loading branch information
rfaircloth-splunk committed Jun 16, 2021
1 parent 5c2ac68 commit 992b5f5
Show file tree
Hide file tree
Showing 7 changed files with 195 additions and 24 deletions.
130 changes: 129 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,129 @@
.DS_Store
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/
2 changes: 1 addition & 1 deletion .releaserc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"branches": [
'+([0-9])?(.{+([0-9]),x}).x',
'master',
'main',
'next',
'next-major',
{
Expand Down
7 changes: 4 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# Container image that runs your code
FROM python:3.7-slim
FROM python:3.7

COPY requirements.txt /
RUN pip install --no-cache-dir -r /requirements.txt
RUN pip install --no-cache-dir --prefer-binary -r /requirements.txt

# Copies your code file from your action repository to the filesystem path `/` of the container
COPY entrypoint.sh /entrypoint.sh
COPY entrypoint.sh /
COPY reporter.py /

# Code file to execute when the docker container starts up (`entrypoint.sh`)
WORKDIR /github/workspace
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -198,4 +198,4 @@
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
31 changes: 17 additions & 14 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
# action.yml
name: 'Splunk AppInspect'
description: 'Run Splunk App insect on a Splunk app directory.'
name: "Splunk AppInspect"
description: "Run Splunk App insect on a Splunk app directory."
inputs:
app-path:
description: 'path to the application directory to be inspected'
required: true
result-file:
description: 'json result file name'
default: 'appinspect_result.json'
app_path:
description: "path to the application directory to be inspected"
default: build/splunkbase
result_file:
description: "json result file name"
default: "appinspect_result.json"
included_tags:
description: "Tags to include"
required: false
excluded_tags:
description: "Tags to exclude"
required: false
outputs:
status:
description: 'value is success/fail based on app inspect result'
description: "value is success/fail based on app inspect result"
runs:
using: 'docker'
image: 'docker://ghcr.io/splunk/addonfactory-packaging-toolkit-action:v1.0.0-develop.1'
args:
- ${{ inputs.app-path }}
- ${{ inputs.result-file }}
using: "docker"
image: "docker://ghcr.io/rfaircloth-splunk/appinspect-cli-action-temp:v1.1.10"
43 changes: 40 additions & 3 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,42 @@
#!/bin/sh -l
#!/usr/bin/env bash
# ########################################################################
# Copyright 2021 Splunk Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ########################################################################

splunk-appinspect inspect $1 --output-file $2 --mode precert > /dev/null
if [ -f $INPUT_APP_PATH ]
then
SCAN=$INPUT_APP_PATH
else
ls $INPUT_APP_PATH/
D=$INPUT_APP_PATH
files=($D/*)
SCAN=${files[0]}
fi
echo scan target $SCAN
if [ ! -f $SCAN ]; then echo Unable to locate package $SCAN aborting; exit 1; fi;

python3 /reporter.py
if [ ! -z $INPUT_INCLUDED_TAGS ]; then INCLUDED_TAGS="--included-tags ${INPUT_INCLUDED_TAGS}"; fi
if [ ! -z $INPUT_EXCLUDED_TAGS ]; then EXCLUDED_TAGS="--excluded-tags ${INPUT_EXCLUDED_TAGS}"; fi

echo "::group::appinspect"
rm -f $INPUT_RESULT_FILE || true 1>/dev/null
echo running: splunk-appinspect inspect $SCAN --output-file $INPUT_RESULT_FILE --mode test $INCLUDED_TAGS $EXCLUDED_TAGS
splunk-appinspect inspect $SCAN --output-file $INPUT_RESULT_FILE --mode test $INCLUDED_TAGS $EXCLUDED_TAGS
if [ ! -f $INPUT_RESULT_FILE ]; then echo no result file; exit 1; fi
echo "::endgroup::"

echo "::group::reporter"
python3 /reporter.py $INPUT_RESULT_FILE
echo "::endgroup::"
4 changes: 3 additions & 1 deletion reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

def main(args):
try:
with open("$2") as f:
with open(args[0]) as f:
result = json.load(f)
if "summary" in result and "failure" in result["summary"]:
failures = result["summary"]["failure"]
Expand Down Expand Up @@ -40,4 +40,6 @@ def main(args):


if __name__ == "__main__":
print(sys.argv[1:])
main(sys.argv[1:])

0 comments on commit 992b5f5

Please sign in to comment.