Skip to content

Commit 1630584

Browse files
sunil-lakshmanabhinav-from-contentstackaravindbuilt
authored
Enh/dx 1221 fetch asset by query (#83)
* Added GCP NA region support (#69) * Removed empty package * Updated changelog file * Added GCP NA support (#68) * Added GCP NA support * Upgraded dependency packages * Updated License file (#72) --------- Co-authored-by: Abhinav Gupta <[email protected]> Co-authored-by: abhinav <[email protected]> * sca-scan.yml * jira.yml * sast-scan.yml * codeql-analysis.yml * Implemented fetch asset by query * Package bump * Fixed Code Injection * Upgraded setuptools version * Upgraded setuptools version * Fixing failed sca scan work flow * Update sca-scan.yml --------- Co-authored-by: Abhinav Gupta <[email protected]> Co-authored-by: abhinav <[email protected]> Co-authored-by: Aravind Kumar <[email protected]>
1 parent c853f0e commit 1630584

File tree

8 files changed

+52
-20
lines changed

8 files changed

+52
-20
lines changed

.github/workflows/jira.yml

+6-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ on:
33
pull_request:
44
types: [opened]
55
jobs:
6-
security:
6+
security-jira:
77
if: ${{ github.actor == 'dependabot[bot]' || github.actor == 'snyk-bot' || contains(github.event.pull_request.head.ref, 'snyk-fix-') || contains(github.event.pull_request.head.ref, 'snyk-upgrade-')}}
88
runs-on: ubuntu-latest
99
steps:
@@ -26,3 +26,8 @@ jobs:
2626
PR: ${{ github.event.pull_request.html_url }}
2727
2828
fields: "${{ secrets.JIRA_FIELDS }}"
29+
- name: Transition issue
30+
uses: atlassian/gajira-transition@v3
31+
with:
32+
issue: ${{ steps.create.outputs.issue }}
33+
transition: ${{ secrets.JIRA_TRANSITION }}

.github/workflows/sast-scan.yml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: SAST Scan
2+
on:
3+
pull_request:
4+
types: [opened, synchronize, reopened]
5+
jobs:
6+
security-sast:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v2
10+
- name: Semgrep Scan
11+
run: docker run -v /var/run/docker.sock:/var/run/docker.sock -v "${PWD}:/src" returntocorp/semgrep semgrep scan --config auto

.github/workflows/sca-scan.yml

+4-3
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ on:
33
pull_request:
44
types: [opened, synchronize, reopened]
55
jobs:
6-
security:
6+
security-sca:
77
runs-on: ubuntu-latest
88
steps:
99
- uses: actions/checkout@master
1010
- name: Run Snyk to check for vulnerabilities
11-
uses: snyk/actions/python-3.10@master
11+
uses: snyk/actions/python@master
1212
env:
1313
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
14+
SNYK_INTEGRATION_VERSION: python-3.11
1415
with:
15-
args: --fail-on=all
16+
args: --fail-on=all --all-projects --skip-unresolved

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# CHANGELOG
22

3+
4+
## _v1.10.0_
5+
6+
### **Date: 03-SEPTEMBER-2024**
7+
8+
- Fetch asset by any other field than UID
9+
310
## _v1.9.0_
411

512
### **Date: 14-MAY-2024**

contentstack/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
__title__ = 'contentstack-delivery-python'
2323
__author__ = 'contentstack'
2424
__status__ = 'debug'
25-
__version__ = 'v1.9.0'
25+
__version__ = 'v1.10.0'
2626
__endpoint__ = 'cdn.contentstack.io'
2727
__email__ = '[email protected]'
2828
__developer_email__ = '[email protected]'

contentstack/assetquery.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,6 @@ def find(self):
176176
177177
"""
178178
if self.parameters is not None and len(self.parameters) > 0:
179-
self.asset_query_params["query"] = json.dumps(self.parameters)
179+
self.asset_query_params["query"] = self.parameters
180180
url = Utils.get_complete_url(self.base_url, self.asset_query_params)
181181
return self.http_instance.get(url)

contentstack/utility.py

+17-9
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import json
77
import logging
8-
from urllib import parse
8+
from urllib.parse import urlencode, urljoin
99

1010
log = logging.getLogger(__name__)
1111

@@ -55,14 +55,22 @@ def do_url_encode(params):
5555
return parse.urlencode(params)
5656

5757
@staticmethod
58-
def get_complete_url(base_url: str, params: dict):
58+
def get_complete_url(base_url: str, params: dict) -> str:
5959
"""
60-
creates complete url using base_url and their respective parameters
61-
:param base_url:
62-
:param params:
63-
:return:
60+
Creates a complete URL using base_url and their respective parameters.
61+
:param base_url: The base URL to which parameters are appended.
62+
:param params: A dictionary of parameters to be included in the URL.
63+
:return: A complete URL with encoded parameters.
6464
"""
65+
# Ensure 'query' is properly serialized as a JSON string without extra quotes
6566
if 'query' in params:
66-
params["query"] = json.dumps(params["query"])
67-
query = parse.urlencode(params)
68-
return f'{base_url}&{query}'
67+
params["query"] = json.dumps(params["query"], separators=(',', ':'))
68+
69+
# Encode parameters
70+
query_string = urlencode(params, doseq=True)
71+
72+
# Join base_url and query_string
73+
if '?' in base_url:
74+
return f'{base_url}&{query_string}'
75+
else:
76+
return f'{base_url}?{query_string}'

requirements.txt

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
twython==3.9.1
2-
setuptools==67.8.0
2+
setuptools~=74.0.0
33
contentstack-utils==1.3.0
44
python-dateutil==2.8.2
5-
requests==2.31.0
5+
requests==2.32.2
66
coverage==7.2.6
77
tox==4.5.1
88
virtualenv==20.23.0
@@ -49,15 +49,15 @@ imagesize==1.4.1
4949
snowballstemmer~=2.2.0
5050
Pygments~=2.15.1
5151
wrapt==1.15.0
52-
certifi==2024.2.2
52+
certifi==2024.7.4
5353
oauthlib==3.2.2
5454
idna==3.7
5555
chardet~=5.2.0
5656
alabaster==0.7.13
57-
zipp==3.15.0
57+
zipp==3.19.1
5858
distlib~=0.3.6
5959
cachetools~=5.3.0
6060
tomlkit~=0.11.8
61-
urllib3==2.0.7
61+
urllib3==2.2.2
6262
exceptiongroup~=1.1.1
6363
iniconfig~=2.0.0

0 commit comments

Comments
 (0)