Skip to content

Fixed license and semgrep issues #282

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ data.then(function(sync_data, err) {

### The MIT License (MIT)

Copyright © 2012-2024 [Contentstack](https://www.contentstack.com). All Rights Reserved
Copyright © 2012-2025 [Contentstack](https://www.contentstack.com). All Rights Reserved

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
2 changes: 1 addition & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export class Stack {
clearByContentType(): Stack;
clearAll(): Stack;
getCacheProvider(): object;
getLastActivities(): Promise<any>;;
getLastActivities(): Promise<any>;
getContentTypes(param?: object): Promise<ContentTypeCollection>;
sync(params: object): Promise<SyncResult>;
imageTransform(url: string, params: any): string;
Expand Down
32 changes: 20 additions & 12 deletions src/core/contentstack.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@ import CacheProvider from './cache-provider/index';
import ContentstackRegion from "./contentstackregion";

/**
* @class
Contentstack
* @description Creates an instance of `Contentstack`.
* @instance
*/

* @class Contentstack
* @description Creates an instance of `Contentstack`.
* @instance
*/
class Contentstack {

constructor(){
Expand Down Expand Up @@ -45,8 +43,8 @@ class Contentstack {
// Iterate through each object in _embedded_items and update the asset link
for (let key in entry._embedded_items) {
let embedded_item = entry._embedded_items[key];
if (Array.isArray(embedded_item)) {

if (Array.isArray(embedded_item)) {
embedded_item.forEach((item) => {

if (item._content_type_uid == 'sys_assets' && item.filename) {
Expand All @@ -62,14 +60,24 @@ class Contentstack {
return;
}
}
}
let _entry = {...entry};
};

let _entry = { ...entry };
const keys = key.split(".");
const unsafeKeys = new Set(["__proto__", "constructor", "prototype"]);

for (const k of keys) {
if (_entry[k]) _entry = _entry[k];
else if (_entry.length) {
// Ensure key is safe before accessing it
if (unsafeKeys.has(k)) continue;

if (_entry && typeof _entry === "object" && _entry !== null && Object.prototype.hasOwnProperty.call(_entry, k)) {
const newEntry = _entry[k];
if (typeof newEntry === "object" && newEntry !== null) {
_entry = newEntry;
}
} else if (Array.isArray(_entry)) {
for (const block of _entry) {
if (block[k]) {
if (block && typeof block === "object" && Object.prototype.hasOwnProperty.call(block, k)) {
_entry = block[k];
}
}
Expand Down
Loading