!C99Shell v. 2.5 [PHP 8 Update] [24.05.2025]!

Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 

uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 

uid=33(www-data) gid=33(www-data) groups=33(www-data) 

Safe-mode: OFF (not secure)

/usr/local/lib/node_modules/strapi/node_modules/strapi-database/lib/validation/   drwxr-xr-x
Free 13.01 GB of 57.97 GB (22.44%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Self remove    Logout    


Viewing file:     check-reserved-names.js (1.97 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
'use strict';

const _ = require('lodash');
const constants = require('../constants');

class ModelError extends Error {
  constructor(message) {
    super(message);
    this.stack = null;
  }
}

const checkReservedAttributeNames = (model, { manager }) => {
  const reservedNames = [...constants.RESERVED_ATTRIBUTE_NAMES];

  if (_.has(model, 'options.timestamps')) {
    const [connectorCreatedAt, connectorUpdatedAt] = manager.connectors.getByConnection(
      model.connection
    ).defaultTimestamps;

    if (_.has(model, 'options.timestamps') && Array.isArray(model.options.timestamps)) {
      const [
        createdAtAttribute = connectorCreatedAt,
        updatedAtAttribute = connectorUpdatedAt,
      ] = model.options.timestamps;

      reservedNames.push(createdAtAttribute, updatedAtAttribute);
    } else {
      reservedNames.push(connectorCreatedAt, connectorUpdatedAt);
    }
  }

  const usedReservedAttributeNames = _.intersection(Object.keys(model.attributes), reservedNames);

  if (usedReservedAttributeNames.length > 0) {
    throw new ModelError(
      `Model "${
        model.modelName
      }" is using reserved attribute names "${usedReservedAttributeNames.join(
        ', '
      )}".\n-> Make sure you are not using a reserved name or overriding the defined timestamp attributes.`
    );
  }
};

const checkReservedModelName = model => {
  if (constants.RESERVED_MODEL_NAMES.includes(model.modelName)) {
    throw new ModelError(
      `"${model.modelName}" is a reserved model name. You need to rename your model and the files associated with it.`
    );
  }
};

const getModelsFrom = source => _.flatMap(source, iteratee => _.values(iteratee.models));

/**
 * Checks that there are no model using reserved names (content type, component, attributes)
 */
module.exports = ({ strapi, manager }) => {
  [...getModelsFrom(strapi.api), ...getModelsFrom(strapi.plugins)].forEach(model => {
    checkReservedModelName(model);
    checkReservedAttributeNames(model, { manager });
  });
};

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ Read-Only ]

:: Make Dir ::
 
[ Read-Only ]
:: Make File ::
 
[ Read-Only ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0083 ]--