Skip to content

Commit e6a3107

Browse files
authored
Add support for web event for gitlab (#18)
1 parent 6d4e171 commit e6a3107

File tree

4 files changed

+24
-8
lines changed

4 files changed

+24
-8
lines changed

scripts/build_container.sh

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
#!/bin/sh
22
VERSION=$(grep -o "__version__.*" socketsecurity/__init__.py | awk '{print $3}' | tr -d "'")
3-
BYPASS_PYPI_BUILD=$1
3+
ENABLE_PYPI_BUILD=$1
4+
STABLE_VERSION=$2
45
echo $VERSION
6+
if [ -z $ENABLE_PYPI_BUILD ] || [ -z $STABLE_VERSION ]; then
7+
echo "$0 pypi-build=enable stable=true"
8+
echo "\tpypi-build: Build and publish a new version of the package to pypi"
9+
echo "\tstable: Only build and publish a new version for the stable docker tag if it has been tested and going on the changelog"
10+
exit
11+
fi
512

6-
if [ -z $BYPASS_PYPI_BUILD ] || [ $BYPASS_PYPI_BUILD -eq 0 ]; then
13+
if [ $ENABLE_PYPI_BUILD = "pypi-build=enable" ]; then
714
python -m build --wheel --sdist
815
twine upload dist/*$VERSION*
916
sleep 240
@@ -12,4 +19,9 @@ fi
1219
docker build --no-cache --build-arg CLI_VERSION=$VERSION --platform linux/amd64,linux/arm64 -t socketdev/cli:$VERSION . \
1320
&& docker build --no-cache --build-arg CLI_VERSION=$VERSION --platform linux/amd64,linux/arm64 -t socketdev/cli:latest . \
1421
&& docker push socketdev/cli:$VERSION \
15-
&& docker push socketdev/cli:latest
22+
&& docker push socketdev/cli:latest
23+
24+
if [ $STABLE_VERSION = "stable=true" ]; then
25+
docker build --no-cache --build-arg CLI_VERSION=$VERSION --platform linux/amd64,linux/arm64 -t socketdev/cli:stable . \
26+
&& docker push socketdev/cli:stable
27+
fi

socketsecurity/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
__author__ = 'socket.dev'
2-
__version__ = '1.0.15'
2+
__version__ = '1.0.17'

socketsecurity/core/__init__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -532,10 +532,14 @@ def create_new_diff(
532532
:return:
533533
"""
534534
if no_change:
535-
return Diff()
535+
diff = Diff()
536+
diff.id = "no_diff_id"
537+
return diff
536538
files = Core.find_files(path, new_files)
537539
if files is None or len(files) == 0:
538-
return Diff()
540+
diff = Diff()
541+
diff.id = "no_diff_id"
542+
return diff
539543
try:
540544
head_full_scan_id = Core.get_head_scan_for_repo(params.repo)
541545
if head_full_scan_id is None or head_full_scan_id == "":

socketsecurity/core/gitlab.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def __init__(self):
9797

9898
@staticmethod
9999
def check_event_type() -> str:
100-
if ci_pipeline_source.lower() == "push" or ci_pipeline_source.lower() == 'merge_request_event':
100+
if ci_pipeline_source.lower() in ["web", 'merge_request_event', "push"]:
101101
if ci_merge_request_iid is None or ci_merge_request_iid == "" or str(ci_merge_request_iid) == "0":
102102
event_type = "main"
103103
else:
@@ -106,7 +106,7 @@ def check_event_type() -> str:
106106
event_type = "comment"
107107
else:
108108
log.error(f"Unknown event type {ci_pipeline_source}")
109-
sys.exit(1)
109+
sys.exit(0)
110110
return event_type
111111

112112
@staticmethod

0 commit comments

Comments
 (0)