# Improper Check for Unusual or Exceptional Conditions (CWE-754) The product does not check or incorrectly checks for unusual or exceptional conditions that are not expected to occur frequently during day to day operation of the product. - Prevalence: मध्यम 1 भाषाएँ कवर की गईं - Impact: उच्च 1 उच्च गंभीरता वाले नियम - Prevention: प्रलेखित 1 फिक्स उदाहरण **OWASP:** Insecure Design (A04:2021-Insecure Design) - #4 ## Description Failing to check for error conditions, return values, or exceptional cases can lead to undefined behavior, crashes, or security vulnerabilities when these conditions occur. ## Prevention 1 Shoulder डिटेक्शन नियमों पर आधारित Improper Check for Unusual Conditions के लिए रोकथाम रणनीतियाँ। ### JavaScript Use multi-phase migrations with data backup before destructive DDL operations like DROP TABLE or DROP COLUMN ## Warning Signs - [HIGH] Migration contains potentially destructive operation: .... Add safety checks and data preservation logic. ## Consequences - DoS - अनधिकृत कोड निष्पादित करना - एप्लिकेशन डेटा पढ़ना ## Mitigations - सभी रिटर्न मानों और त्रुटि स्थितियों की जाँच करें - एज केसों और असाधारण स्थितियों को स्पष्ट रूप से संभालें - रक्षात्मक प्रोग्रामिंग प्रथाओं को अपनाएँ ## Detection - Total rules: 1 - Languages: javascript, typescript ## Rules by Language ### Javascript (1 rules) - **TypeORM Unsafe Database Migration** [HIGH]: Unsafe migrations with DROP TABLE/COLUMN operations without backups cause permanent data loss and application crashes from schema mismatches. - Remediation: Backup data before destructive operations and use multi-phase migrations. ```typescript export class SafeColumnRemoval implements MigrationInterface { public async up(queryRunner: QueryRunner): Promise { // Backup before dropping await queryRunner.query(` CREATE TABLE "user_email_backup" AS SELECT id, email FROM "user" `); await queryRunner.dropColumn('user', 'email'); } } ``` Learn more: https://shoulder.dev/learn/typescript/cwe-754/unsafe-migration ### Typescript (1 rules) - **TypeORM Unsafe Database Migration** [HIGH]: Unsafe migrations with DROP TABLE/COLUMN operations without backups cause permanent data loss and application crashes from schema mismatches. - Remediation: Backup data before destructive operations and use multi-phase migrations. ```typescript export class SafeColumnRemoval implements MigrationInterface { public async up(queryRunner: QueryRunner): Promise { // Backup before dropping await queryRunner.query(` CREATE TABLE "user_email_backup" AS SELECT id, email FROM "user" `); await queryRunner.dropColumn('user', 'email'); } } ``` Learn more: https://shoulder.dev/learn/typescript/cwe-754/unsafe-migration