@contentstack/datasync-mongodb-sdk 1.0.9-beta.1 → 1.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/issues-jira.yml +31 -0
- package/.github/workflows/policy-scan.yml +27 -0
- package/.github/workflows/release.yml +6 -6
- package/contentstack-datasync-mongodb-sdk-1.0.11.tgz +0 -0
- package/dist/stack.js +46 -10
- package/package.json +2 -2
- package/typings/stack.d.ts +1 -0
- package/.github/workflows/jira.yml +0 -33
- package/.github/workflows/sast-scan.yml +0 -11
- package/contentstack-datasync-mongodb-sdk-1.0.9-beta.1.tgz +0 -0
- /package/{LICENCE → LICENSE} +0 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
name: Create Jira Ticket for Github Issue
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
issues:
|
|
5
|
+
types: [opened]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
issue-jira:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
steps:
|
|
11
|
+
|
|
12
|
+
- name: Login to Jira
|
|
13
|
+
uses: atlassian/gajira-login@master
|
|
14
|
+
env:
|
|
15
|
+
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
|
|
16
|
+
JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }}
|
|
17
|
+
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}
|
|
18
|
+
|
|
19
|
+
- name: Create Jira Issue
|
|
20
|
+
id: create_jira
|
|
21
|
+
uses: atlassian/gajira-create@master
|
|
22
|
+
with:
|
|
23
|
+
project: ${{ secrets.JIRA_PROJECT }}
|
|
24
|
+
issuetype: ${{ secrets.JIRA_ISSUE_TYPE }}
|
|
25
|
+
summary: Github | Issue | ${{ github.event.repository.name }} | ${{ github.event.issue.title }}
|
|
26
|
+
description: |
|
|
27
|
+
*GitHub Issue:* ${{ github.event.issue.html_url }}
|
|
28
|
+
|
|
29
|
+
*Description:*
|
|
30
|
+
${{ github.event.issue.body }}
|
|
31
|
+
fields: "${{ secrets.ISSUES_JIRA_FIELDS }}"
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
name: Checks the security policy and configurations
|
|
2
|
+
on:
|
|
3
|
+
pull_request:
|
|
4
|
+
types: [opened, synchronize, reopened]
|
|
5
|
+
jobs:
|
|
6
|
+
security-policy:
|
|
7
|
+
if: github.event.repository.visibility == 'public'
|
|
8
|
+
runs-on: ubuntu-latest
|
|
9
|
+
defaults:
|
|
10
|
+
run:
|
|
11
|
+
shell: bash
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@master
|
|
14
|
+
- name: Checks for SECURITY.md policy file
|
|
15
|
+
run: |
|
|
16
|
+
if ! [[ -f "SECURITY.md" || -f ".github/SECURITY.md" ]]; then exit 1; fi
|
|
17
|
+
security-license:
|
|
18
|
+
if: github.event.repository.visibility == 'public'
|
|
19
|
+
runs-on: ubuntu-latest
|
|
20
|
+
defaults:
|
|
21
|
+
run:
|
|
22
|
+
shell: bash
|
|
23
|
+
steps:
|
|
24
|
+
- uses: actions/checkout@master
|
|
25
|
+
- name: Checks for License file
|
|
26
|
+
run: |
|
|
27
|
+
if ! [[ -f "LICENSE" || -f "License.txt" || -f "LICENSE.md" ]]; then exit 1; fi
|
|
@@ -2,7 +2,7 @@ name: Release
|
|
|
2
2
|
|
|
3
3
|
on:
|
|
4
4
|
push:
|
|
5
|
-
branches: [
|
|
5
|
+
branches: [master]
|
|
6
6
|
|
|
7
7
|
jobs:
|
|
8
8
|
build:
|
|
@@ -28,12 +28,12 @@ jobs:
|
|
|
28
28
|
uses: codex-team/action-nodejs-package-info@v1.1
|
|
29
29
|
|
|
30
30
|
# Install npm-pack-all to create a package archive
|
|
31
|
-
- name: Install npm
|
|
32
|
-
run: npm install npm-pack
|
|
33
|
-
|
|
31
|
+
- name: Install npm pack
|
|
32
|
+
run: npm install npm-pack
|
|
33
|
+
|
|
34
34
|
# Pack the package into a .tgz archive
|
|
35
35
|
- name: Pack the npm package
|
|
36
|
-
run:
|
|
36
|
+
run: npm pack
|
|
37
37
|
|
|
38
38
|
# Publish the package to npm
|
|
39
39
|
- name: Publish to npm
|
|
@@ -41,7 +41,7 @@ jobs:
|
|
|
41
41
|
uses: JS-DevTools/npm-publish@v3
|
|
42
42
|
with:
|
|
43
43
|
token: ${{ secrets.NPM_TOKEN }}
|
|
44
|
-
access: public # Uncomment this line if you want to publish the package as public for first time
|
|
44
|
+
# access: public # Uncomment this line if you want to publish the package as public for first time
|
|
45
45
|
|
|
46
46
|
# Auto-tag the new version if a change is detected
|
|
47
47
|
- name: Auto-tag new version
|
|
Binary file
|
package/dist/stack.js
CHANGED
|
@@ -1815,8 +1815,9 @@ class Stack {
|
|
|
1815
1815
|
return this.includeReferenceIteration(queries, schemaList, locale, pendingPath, shelf);
|
|
1816
1816
|
});
|
|
1817
1817
|
}
|
|
1818
|
-
fetchPathDetails(data, locale, pathArr, queryBucket, shelf, assetsOnly = false, parent, pos, counter = 0) {
|
|
1818
|
+
fetchPathDetails(data = {}, locale, pathArr, queryBucket, shelf = [], assetsOnly = false, parent = {}, pos, counter = 0) {
|
|
1819
1819
|
if (counter === (pathArr.length)) {
|
|
1820
|
+
queryBucket = this.sanitizeQueryBucket(queryBucket);
|
|
1820
1821
|
if (data && typeof data === 'object') {
|
|
1821
1822
|
if (data instanceof Array && data.length) {
|
|
1822
1823
|
data.forEach((elem, idx) => {
|
|
@@ -1883,13 +1884,13 @@ class Stack {
|
|
|
1883
1884
|
// tslint:disable-next-line: prefer-for-of
|
|
1884
1885
|
for (let i = 0; i < data.length; i++) {
|
|
1885
1886
|
if (data[i][currentField]) {
|
|
1886
|
-
this.fetchPathDetails(data[i][currentField], locale, pathArr, queryBucket, shelf, assetsOnly, data[i], currentField, counter);
|
|
1887
|
+
this.fetchPathDetails(data[i][currentField], locale, pathArr, this.sanitizeQueryBucket(queryBucket), shelf, assetsOnly, data[i], currentField, counter);
|
|
1887
1888
|
}
|
|
1888
1889
|
}
|
|
1889
1890
|
}
|
|
1890
1891
|
else {
|
|
1891
1892
|
if (data[currentField]) {
|
|
1892
|
-
this.fetchPathDetails(data[currentField], locale, pathArr, queryBucket, shelf, assetsOnly, data, currentField, counter);
|
|
1893
|
+
this.fetchPathDetails(data[currentField], locale, pathArr, this.sanitizeQueryBucket(queryBucket), shelf, assetsOnly, data, currentField, counter);
|
|
1893
1894
|
}
|
|
1894
1895
|
}
|
|
1895
1896
|
}
|
|
@@ -1899,14 +1900,12 @@ class Stack {
|
|
|
1899
1900
|
bindLeftoverAssets(queries, locale, pointerList) {
|
|
1900
1901
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1901
1902
|
// const contents = await readFile(getAssetsPath(locale) + '.json')
|
|
1902
|
-
|
|
1903
|
-
throw new Error('Invalid queries provided');
|
|
1904
|
-
}
|
|
1903
|
+
const queriesSanitize = this.sanitizeQueryBucket(queries);
|
|
1905
1904
|
const filteredAssets = yield this.db.collection((0, util_1.getCollectionName)({
|
|
1906
1905
|
content_type_uid: this.types.assets,
|
|
1907
1906
|
locale,
|
|
1908
1907
|
}, this.collectionNames))
|
|
1909
|
-
.find(
|
|
1908
|
+
.find(queriesSanitize)
|
|
1910
1909
|
.project({
|
|
1911
1910
|
_content_type_uid: 0,
|
|
1912
1911
|
_id: 0,
|
|
@@ -1968,11 +1967,12 @@ class Stack {
|
|
|
1968
1967
|
if (!this.sanityQueryAny(query)) {
|
|
1969
1968
|
throw new Error('Invalid query provided');
|
|
1970
1969
|
}
|
|
1970
|
+
const querySanitize = this.sanitizeQueryBucket(query);
|
|
1971
1971
|
const schemas = yield this.db.collection((0, util_1.getCollectionName)({
|
|
1972
1972
|
content_type_uid: this.types.content_types,
|
|
1973
1973
|
locale,
|
|
1974
1974
|
}, this.collectionNames))
|
|
1975
|
-
.find(
|
|
1975
|
+
.find(querySanitize)
|
|
1976
1976
|
.project({
|
|
1977
1977
|
_assets: 1,
|
|
1978
1978
|
_id: 0,
|
|
@@ -2055,11 +2055,12 @@ class Stack {
|
|
|
2055
2055
|
if (!this.sanitizeIQuery(query)) {
|
|
2056
2056
|
throw new Error('Invalid queries provided');
|
|
2057
2057
|
}
|
|
2058
|
+
const sanitizeQuery = this.sanitizeQueryBucket(query);
|
|
2058
2059
|
const result = yield this.db.collection((0, util_1.getCollectionName)({
|
|
2059
2060
|
content_type_uid: 'entries',
|
|
2060
2061
|
locale,
|
|
2061
2062
|
}, this.collectionNames))
|
|
2062
|
-
.find(
|
|
2063
|
+
.find(sanitizeQuery)
|
|
2063
2064
|
.project({
|
|
2064
2065
|
_content_type_uid: 0,
|
|
2065
2066
|
_id: 0,
|
|
@@ -2114,7 +2115,7 @@ class Stack {
|
|
|
2114
2115
|
// iterate over each path in the entries and fetch the references
|
|
2115
2116
|
// while fetching, keep track of their location
|
|
2116
2117
|
for (let i = 0, j = paths.length; i < j; i++) {
|
|
2117
|
-
this.fetchPathDetails(entries, locale, paths[i].split('.'), queries, objectPointerList, true, entries, 0);
|
|
2118
|
+
this.fetchPathDetails(entries, locale, paths[i].split('.'), this.sanitizeQueryBucket(queries), objectPointerList, true, entries, 0);
|
|
2118
2119
|
}
|
|
2119
2120
|
// even after traversing, if no references were found, simply return the entries found thusfar
|
|
2120
2121
|
if (objectPointerList.length === 0) {
|
|
@@ -2268,5 +2269,40 @@ class Stack {
|
|
|
2268
2269
|
}
|
|
2269
2270
|
return true;
|
|
2270
2271
|
}
|
|
2272
|
+
sanitizeQueryBucket(queryBucket) {
|
|
2273
|
+
if (!queryBucket || typeof queryBucket !== 'object') {
|
|
2274
|
+
return { $or: [{ _id: { $exists: true } }] };
|
|
2275
|
+
}
|
|
2276
|
+
const sanitized = { $or: [] };
|
|
2277
|
+
if (!Array.isArray(queryBucket.$or)) {
|
|
2278
|
+
return { $or: [{ _id: { $exists: true } }] };
|
|
2279
|
+
}
|
|
2280
|
+
for (const item of queryBucket.$or) {
|
|
2281
|
+
if (!item || typeof item !== 'object') {
|
|
2282
|
+
continue;
|
|
2283
|
+
}
|
|
2284
|
+
const safeItem = {};
|
|
2285
|
+
if (typeof item._content_type_uid === 'string') {
|
|
2286
|
+
safeItem._content_type_uid = item._content_type_uid;
|
|
2287
|
+
}
|
|
2288
|
+
if (typeof item.uid === 'string') {
|
|
2289
|
+
safeItem.uid = item.uid;
|
|
2290
|
+
}
|
|
2291
|
+
if (typeof item.locale === 'string') {
|
|
2292
|
+
safeItem.locale = item.locale;
|
|
2293
|
+
}
|
|
2294
|
+
if (item._version && typeof item._version === 'object' &&
|
|
2295
|
+
typeof item._version.$exists === 'boolean') {
|
|
2296
|
+
safeItem._version = { $exists: item._version.$exists };
|
|
2297
|
+
}
|
|
2298
|
+
if (safeItem._content_type_uid && safeItem.uid) {
|
|
2299
|
+
sanitized.$or.push(safeItem);
|
|
2300
|
+
}
|
|
2301
|
+
}
|
|
2302
|
+
if (sanitized.$or.length === 0) {
|
|
2303
|
+
return { $or: [{ _id: { $exists: true } }] };
|
|
2304
|
+
}
|
|
2305
|
+
return sanitized;
|
|
2306
|
+
}
|
|
2271
2307
|
}
|
|
2272
2308
|
exports.Stack = Stack;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"author": "Contentstack Ecosystem <ecosystem@contentstack.com>",
|
|
3
3
|
"name": "@contentstack/datasync-mongodb-sdk",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.11",
|
|
5
5
|
"description": "Mongodb query wrapper around contents synced via @contentstack/content-store-mongodb",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"scripts": {
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"lodash": "^4.17.21",
|
|
21
21
|
"mongodb": "^6.12.0",
|
|
22
|
-
"npm-pack
|
|
22
|
+
"npm-pack": "^1.0.0",
|
|
23
23
|
"sift": "^17.1.3"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
package/typings/stack.d.ts
CHANGED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
name: Create JIRA ISSUE
|
|
2
|
-
on:
|
|
3
|
-
pull_request:
|
|
4
|
-
types: [opened]
|
|
5
|
-
jobs:
|
|
6
|
-
security-jira:
|
|
7
|
-
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-')}}
|
|
8
|
-
runs-on: ubuntu-latest
|
|
9
|
-
steps:
|
|
10
|
-
- uses: actions/checkout@v2
|
|
11
|
-
- name: Login into JIRA
|
|
12
|
-
uses: atlassian/gajira-login@master
|
|
13
|
-
env:
|
|
14
|
-
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
|
|
15
|
-
JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }}
|
|
16
|
-
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}
|
|
17
|
-
- name: Create a JIRA Issue
|
|
18
|
-
id: create
|
|
19
|
-
uses: atlassian/gajira-create@master
|
|
20
|
-
with:
|
|
21
|
-
project: ${{ secrets.JIRA_PROJECT }}
|
|
22
|
-
issuetype: ${{ secrets.JIRA_ISSUE_TYPE }}
|
|
23
|
-
summary: |
|
|
24
|
-
Snyk | Vulnerability | ${{ github.event.repository.name }} | ${{ github.event.pull_request.title }}
|
|
25
|
-
description: |
|
|
26
|
-
PR: ${{ github.event.pull_request.html_url }}
|
|
27
|
-
|
|
28
|
-
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 }}
|
|
@@ -1,11 +0,0 @@
|
|
|
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
|
|
Binary file
|
/package/{LICENCE → LICENSE}
RENAMED
|
File without changes
|