Skip to content

Commit 12e992c

Browse files
Merge pull request #12 from contentstack/staging
DX | 12-01-2026 | Release
2 parents 1905dcd + 4dc32fd commit 12e992c

13 files changed

Lines changed: 127 additions & 53 deletions

File tree

.github/workflows/check-branch.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ jobs:
88
runs-on: ubuntu-latest
99
steps:
1010
- name: Comment PR
11-
if: github.base_ref == 'master' && github.head_ref != 'next'
11+
if: github.base_ref == 'master' && github.head_ref != 'staging'
1212
uses: thollander/actions-comment-pull-request@v2
1313
with:
1414
message: |
15-
We regret to inform you that you are currently not able to merge your changes into the master branch due to restrictions applied by our SRE team. To proceed with merging your changes, we kindly request that you create a pull request from the next branch. Our team will then review the changes and work with you to ensure a successful merge into the master branch.
15+
We regret to inform you that you are currently not able to merge your changes into the master branch due to restrictions applied by our SRE team. To proceed with merging your changes, we kindly request that you create a pull request from the staging branch. Our team will then review the changes and work with you to ensure a successful merge into the master branch.
1616
- name: Check branch
17-
if: github.base_ref == 'master' && github.head_ref != 'next'
17+
if: github.base_ref == 'master' && github.head_ref != 'staging'
1818
run: |
19-
echo "ERROR: We regret to inform you that you are currently not able to merge your changes into the master branch due to restrictions applied by our SRE team. To proceed with merging your changes, we kindly request that you create a pull request from the next branch. Our team will then review the changes and work with you to ensure a successful merge into the master branch."
20-
exit 1
19+
echo "ERROR: We regret to inform you that you are currently not able to merge your changes into the master branch due to restrictions applied by our SRE team. To proceed with merging your changes, we kindly request that you create a pull request from the staging branch. Our team will then review the changes and work with you to ensure a successful merge into the master branch."
20+
exit 1

.github/workflows/sca-scan.yml

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,31 @@ jobs:
66
security-sca:
77
runs-on: ubuntu-latest
88
steps:
9-
- uses: actions/checkout@master
10-
- name: Run Snyk to check for vulnerabilities
11-
uses: snyk/actions/node@master
12-
env:
13-
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
9+
- uses: actions/checkout@v4
10+
11+
- name: Set up Dart
12+
uses: dart-lang/setup-dart@v1
1413
with:
15-
args: --all-projects --fail-on=all
14+
sdk: stable
15+
16+
- name: Install dependencies
17+
run: dart pub get
18+
19+
- name: Check for outdated dependencies
20+
run: dart pub outdated || true
21+
22+
- name: Run OSV Scanner for vulnerabilities
23+
run: |
24+
curl -L https://github.com/google/osv-scanner/releases/latest/download/osv-scanner_linux_amd64 -o osv-scanner
25+
chmod +x osv-scanner
26+
./osv-scanner --lockfile=pubspec.lock --format=json --output=osv-results.json || true
27+
28+
- name: Display OSV Scanner results
29+
if: always()
30+
run: |
31+
if [ -f osv-results.json ]; then
32+
echo "OSV Scanner Results:"
33+
cat osv-results.json
34+
else
35+
echo "No vulnerabilities found!"
36+
fi

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## v1.1.1
4+
5+
- Improved error messages
6+
___________________
7+
38
## v1.1.0
49

510
Implemented SRTE functions: :tada:

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# MIT License
22

3-
Copyright (c) 2012 - 2021 Contentstack
3+
Copyright (c) 2012 - 2026 Contentstack
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

SECURITY.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
## Security
2+
3+
Contentstack takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations.
4+
5+
If you believe you have found a security vulnerability in any Contentstack-owned repository, please report it to us as described below.
6+
7+
## Reporting Security Issues
8+
9+
**Please do not report security vulnerabilities through public GitHub issues.**
10+
11+
Send email to [security@contentstack.com](mailto:security@contentstack.com).
12+
13+
You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message.
14+
15+
Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue:
16+
17+
* Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
18+
* Full paths of source file(s) related to the manifestation of the issue
19+
* The location of the affected source code (tag/branch/commit or direct URL)
20+
* Any special configuration required to reproduce the issue
21+
* Step-by-step instructions to reproduce the issue
22+
* Proof-of-concept or exploit code (if possible)
23+
* Impact of the issue, including how an attacker might exploit the issue
24+
25+
This information will help us triage your report more quickly.
26+
27+
[https://www.contentstack.com/trust/](https://www.contentstack.com/trust/)

lib/contentstack_utils.dart

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
library contentstack_utils;
22

3+
import 'package:contentstack_utils/src/constants/ErrorMessages.dart';
34
import 'package:contentstack_utils/src/helper/Automate.dart';
45
import 'package:contentstack_utils/src/model/Option.dart';
56
export 'src/embedded/StyleType.dart';
@@ -8,14 +9,14 @@ export 'src/helper/Metadata.dart';
89
class Utils {
910
static void render(jsonObject, List<String> rteKeys, Option option) {
1011
if (!Automate.isValidJson(jsonObject)) {
11-
throw FormatException('Invalid file, Can\'t process the json file');
12+
throw FormatException(ErrorMessages.invalidJsonFile);
1213
}
1314

1415
if (jsonObject is List) {
1516
for (var entry in jsonObject) {
1617
render(entry, rteKeys, option);
1718
}
18-
} else if (jsonObject is Map<String, Object>) {
19+
} else if (jsonObject is Map) {
1920
if (jsonObject.containsKey('_embedded_items')) {
2021
if (rteKeys.isNotEmpty) {
2122
for (var path in rteKeys) {
@@ -24,8 +25,8 @@ class Utils {
2425
});
2526
}
2627
} else {
27-
Map<String, Object> embeddedKeys = jsonObject['_embedded_items'];
28-
rteKeys = embeddedKeys.keys.toList();
28+
Map embeddedKeys = jsonObject['_embedded_items'] as Map;
29+
rteKeys = embeddedKeys.keys.toList().cast<String>();
2930
embeddedKeys.keys.forEach((keyPath) {
3031
Automate.find_embed_keys(jsonObject, keyPath, (rteContent) {
3132
return renderContent(rteContent, jsonObject, option);
@@ -34,7 +35,7 @@ class Utils {
3435
}
3536
}
3637
} else {
37-
FormatException('Invalid file for embedded objects');
38+
throw FormatException(ErrorMessages.invalidEmbeddedObjectsInput);
3839
}
3940
}
4041

@@ -69,7 +70,7 @@ class Utils {
6970

7071
static void jsonToHTML(items, List<String> key_path, Option option) {
7172
if (!Automate.isValidJson(items)) {
72-
throw FormatException('Invalid file, Can\'t process the json file');
73+
throw FormatException(ErrorMessages.invalidJsonFile);
7374
}
7475

7576
if (items is List) {

lib/src/GQL.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
import 'package:contentstack_utils/src/constants/ErrorMessages.dart';
12
import 'package:contentstack_utils/src/helper/Automate.dart';
23
import 'package:contentstack_utils/src/model/Option.dart';
34

45
class GQL {
56
static void jsonToHTML(items, List<String> key_path, Option option) {
67
if (!Automate.isValidJson(items)) {
7-
throw FormatException('Invalid file, Can\'t process the json file');
8+
throw FormatException(ErrorMessages.invalidJsonFile);
89
}
910

1011
if (items is List) {
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/// Error message constants for Contentstack Utils
2+
///
3+
/// This file contains all error messages used throughout the library
4+
/// to ensure consistency and ease of maintenance.
5+
class ErrorMessages {
6+
// JSON validation errors
7+
static const String invalidJsonFile =
8+
'Invalid JSON file. Provide a valid JSON file and try again.';
9+
10+
// Embedded objects errors
11+
static const String invalidEmbeddedObjectsInput =
12+
'Invalid input for embedded objects. Expected a Map or List.';
13+
}
14+

lib/src/helper/Automate.dart

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@ class Automate {
2121
}
2222
}
2323

24-
static Map findEmbeddedItems(Map jsonObject, Metadata metadata) {
24+
static Map? findEmbeddedItems(Map jsonObject, Metadata metadata) {
2525
var keys = jsonObject.keys;
2626
for (var item in keys) {
2727
List jsonArray = jsonObject[item];
2828
var filteredContent = jsonArray
29-
.firstWhere((element) => element['uid'] == metadata.getItemUid);
30-
return filteredContent;
29+
.firstWhere((element) => element['uid'] == metadata.getItemUid, orElse: () => null);
30+
if (filteredContent != null) {
31+
return filteredContent;
32+
}
3133
}
3234
return null;
3335
}
@@ -169,7 +171,7 @@ class Automate {
169171
}
170172
}
171173

172-
static Object findEmbeddedEntry(List jsonList, Metadata metadata) {
174+
static Object? findEmbeddedEntry(List jsonList, Metadata metadata) {
173175
for (var obj in jsonList) {
174176
if (obj is Map) {
175177
if (obj['uid'] == metadata.getItemUid) {
@@ -189,8 +191,8 @@ class Automate {
189191
return null;
190192
}
191193

192-
static String getStringOption(Option option, Metadata meta, Map content) {
193-
var stringOption = option.renderOption(content, meta);
194+
static String getStringOption(Option option, Metadata meta, Object content) {
195+
var stringOption = option.renderOption(content as Map, meta);
194196
return stringOption;
195197
}
196198

lib/src/helper/Metadata.dart

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ import 'dart:collection';
33
import 'package:html/dom.dart';
44

55
class Metadata {
6-
String text;
7-
String itemType;
8-
String itemUid;
9-
String contentTypeUid;
10-
String styleType;
11-
String outerHTML;
12-
LinkedHashMap<dynamic, dynamic> attributes;
6+
String? text;
7+
String? itemType;
8+
String? itemUid;
9+
String? contentTypeUid;
10+
String? styleType;
11+
String? outerHTML;
12+
LinkedHashMap<dynamic, dynamic>? attributes;
1313

1414
Metadata(
1515
{this.text,
@@ -20,19 +20,19 @@ class Metadata {
2020
this.outerHTML,
2121
this.attributes});
2222

23-
String get getText => text;
23+
String? get getText => text;
2424

25-
String get getItemType => itemType;
25+
String? get getItemType => itemType;
2626

27-
String get getItemUid => itemUid;
27+
String? get getItemUid => itemUid;
2828

29-
String get getContentTypeUid => contentTypeUid;
29+
String? get getContentTypeUid => contentTypeUid;
3030

31-
String get getStyleType => styleType;
31+
String? get getStyleType => styleType;
3232

33-
String get getOuterHTML => outerHTML;
33+
String? get getOuterHTML => outerHTML;
3434

35-
LinkedHashMap<dynamic, dynamic> get getAttributes => attributes;
35+
LinkedHashMap<dynamic, dynamic>? get getAttributes => attributes;
3636

3737
Metadata.element(Element element) {
3838
text = element.text;

0 commit comments

Comments
 (0)