Skip to content

Commit e6a09a0

Browse files
authored
Merge pull request #1 from sbs2001/report-fix
Cloud check fail fix
2 parents 8e63f43 + 31dac35 commit e6a09a0

34 files changed

+835
-403
lines changed

.github/workflows/appinspect.yaml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: App inspect tests
2+
on:
3+
push:
4+
pull_request:
5+
6+
jobs:
7+
deploy:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout
11+
uses: actions/checkout@v2
12+
13+
- name: Set up Python
14+
uses: actions/setup-python@v2
15+
with:
16+
python-version: '3.9.16'
17+
18+
- name: Install Splunk Packaging Toolkit
19+
run: |
20+
curl https://download.splunk.com/misc/packaging-toolkit/splunk-packaging-toolkit-1.0.1.tar.gz -o /tmp/spl.tar.gz
21+
pip install /tmp/spl.tar.gz
22+
23+
- name: Create Splunk App Package
24+
run: |
25+
rm -rf .git .github .gitignore
26+
slim package .
27+
cp crowdsec-splunk-app-*.tar.gz /tmp/crowdsec-splunk-app.tar.gz
28+
29+
- name: Retrieve App Inspect Report
30+
run: |
31+
TOKEN=$(curl -u '${{ secrets.SPLUNKBASE_USERNAME }}:${{ secrets.SPLUNKBASE_PASSWORD }}' --url 'https://api.splunk.com/2.0/rest/login/splunk' | jq -r .data.token)
32+
echo "::add-mask::$TOKEN"
33+
REPORT_HREF=$(curl -X POST \
34+
-H "Authorization: bearer $TOKEN" \
35+
-H "Cache-Control: no-cache" \
36+
-F "app_package=@/tmp/crowdsec-splunk-app.tar.gz" \
37+
--url "https://appinspect.splunk.com/v1/app/validate"| jq -r .links[1].href)
38+
REPORT_URL="https://appinspect.splunk.com$REPORT_HREF"
39+
sleep 10
40+
curl -X GET \
41+
-H "Authorization: bearer $TOKEN" \
42+
--url $REPORT_URL > /tmp/report
43+
44+
- name: Upload App Inspect Report
45+
uses: actions/upload-artifact@v2
46+
with:
47+
name: report
48+
path: /tmp/report
49+
50+
- name: Check App Inspect Report Results
51+
run: |
52+
if grep -q '"result": "failure"' /tmp/report; then
53+
echo "::error::App inspect check failed"
54+
exit 1
55+
else
56+
exit 0
57+
fi

bin/splunklib/__init__.py

100755100644
Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,20 @@
1616

1717
from __future__ import absolute_import
1818
from splunklib.six.moves import map
19-
__version_info__ = (1, 6, 12)
19+
import logging
20+
21+
DEFAULT_LOG_FORMAT = '%(asctime)s, Level=%(levelname)s, Pid=%(process)s, Logger=%(name)s, File=%(filename)s, ' \
22+
'Line=%(lineno)s, %(message)s'
23+
DEFAULT_DATE_FORMAT = '%Y-%m-%d %H:%M:%S %Z'
24+
25+
26+
# To set the logging level of splunklib
27+
# ex. To enable debug logs, call this method with parameter 'logging.DEBUG'
28+
# default logging level is set to 'WARNING'
29+
def setup_logging(level, log_format=DEFAULT_LOG_FORMAT, date_format=DEFAULT_DATE_FORMAT):
30+
logging.basicConfig(level=level,
31+
format=log_format,
32+
datefmt=date_format)
33+
34+
__version_info__ = (1, 7, 3)
2035
__version__ = ".".join(map(str, __version_info__))

0 commit comments

Comments
 (0)