From c6c476ff76768cf7adfb1c4ec5d18e676f70ff0c Mon Sep 17 00:00:00 2001 From: stephenminakian Date: Sun, 7 Sep 2025 12:03:21 -0600 Subject: [PATCH] Added xsd support --- CLAUDE.md | 51 ++++++ software-rules-html-xml.xml | 321 ++++++++++++++++++++++++++++++++++++ software-rules.xsd.txt | 74 +++++++++ xsd_xml_viewer.html | 159 +++++------------- 4 files changed, 486 insertions(+), 119 deletions(-) create mode 100644 CLAUDE.md create mode 100644 software-rules-html-xml.xml create mode 100644 software-rules.xsd.txt diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..74dee01 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,51 @@ +# CLAUDE.md + +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. + +## Project Overview + +This is a simple XML requirements viewer application consisting of: +- `xml_requirements_viewer.html` - A standalone HTML application for viewing XML requirements +- `sample_requirements.xml` - A sample XML file containing formatted requirements + +## Architecture + +The project is a single-page HTML application with embedded CSS and JavaScript. No build process, dependencies, or server is required - it runs entirely in the browser. + +### Core Components + +- **HTML Structure**: Standard HTML5 with responsive design +- **CSS Styling**: Embedded styles with dark mode support via `@media (prefers-color-scheme: dark)` +- **JavaScript Functionality**: + - Drag-and-drop file handling + - XML parsing using DOMParser + - Dynamic DOM manipulation for requirements display + +### XML Structure + +The viewer expects XML files with this structure: +```xml + + + Title + High/Medium/Low + Category + HTML-formatted requirement text with custom tags + Active/Draft + + +``` + +### Custom XML Tags Supported + +The viewer supports various custom formatting tags within `` elements: +- Text formatting: ``, ``, ``, ``, ``, ``, ``, `` +- Code elements: ``, ``, ``, ``, `
`
+- Semantic tags: ``, ``, ``, ``
+- Technical tags: ``, ``, ``, ``, ``
+- Structure: `
`, `
`, `
    `, `
      `, `
    1. `, `
      ` +- References: ``, ``, `` + +## Usage + +Open `xml_requirements_viewer.html` in a web browser and drag/drop or select XML files to view formatted requirements. \ No newline at end of file diff --git a/software-rules-html-xml.xml b/software-rules-html-xml.xml new file mode 100644 index 0000000..c64aa70 --- /dev/null +++ b/software-rules-html-xml.xml @@ -0,0 +1,321 @@ + + + + + SEC-001 + Password Complexity Check + Security + Critical + Active + + Ensures passwords meet minimum complexity requirements: +
        +
      • At least 12 characters in length
      • +
      • Contains uppercase and lowercase letters
      • +
      • Includes numbers and special characters
      • +
      • No dictionary words allowed
      • +
      +
      A strong password is your first line of defense.
      +
      + password.length >= 13 AND hasUpperCase AND hasLowerCase AND hasNumber AND hasSpecialChar + VALIDATE_PASSWORD + Error: Password must be at least 12 characters and contain uppercase, lowercase, numbers, and special characters + UserRegistration + PasswordReset + AccountCreation + admin + 2024-01-15 + security_team + 2024-06-20 + authentication + security + compliance + 5 + true +
      + + + PERF-002 + Query Timeout Limit + Performance + High + Active + +

      Performance Protection Rule

      +

      This rule prevents database queries from running longer than 30 seconds.

      +

      Key settings:

      + + + + + + + + + + + + + +
      ParameterValue
      Max Execution Time30000ms
      ActionTerminate Query
      +
      + Note: This limit can be overridden for batch operations. +
      +
      if (query.executionTime > 30000) {
      +    return TERMINATE;
      +}
      + TERMINATE_QUERY + Query execution exceeded maximum allowed time of 30 seconds + DatabaseOperations + ReportGeneration + dba_team + 2024-02-10 + performance_team + 2024-11-05 + database + performance + 3 + true +
      + + + VAL-003 + Email Format Validation + DataValidation + Medium + Testing + + Validates email addresses against RFC 5322 standard. +

      + Valid format: user@domain.com +
      + Invalid formats: +
        +
      • user@
      • +
      • @domain.com
      • +
      • user domain.com
      • +
      +
      + Click for regex pattern + ^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$ +
      +
      + email.matches(RFC5322_REGEX) + VALIDATE_EMAIL + Please enter a valid email address + UserProfile + ContactForm + dev_team + 2024-03-22 + validation + email + 1 + true +
      + + + BUS-004 + Transaction Amount Limit + BusinessLogic + High + Active + +

      Transaction Limits by User Tier

      +
        +
      1. Basic Tier: Maximum $1,000 per transaction
      2. +
      3. Premium Tier: Maximum $10,000 per transaction
      4. +
      5. Enterprise Tier: Maximum $100,000 per transaction
      6. +
      +

      Transactions exceeding these limits will be automatically blocked and flagged for review.

      +

      For limit increases, contact support@example.com

      +
      + transaction.amount > user.maxTransactionLimit + BLOCK_TRANSACTION + Transaction amount of ${amount} exceeds your account limit + PaymentProcessing + WireTransfers + ACHTransfers + compliance_officer + 2024-01-05 + risk_management + 2024-09-15 + financial + limits + risk + 4 + true +
      + + + COMP-005 + GDPR Data Retention + Compliance + Critical + Active + +

      āš ļø GDPR Compliance Rule

      +

      Personal data retention must comply with GDPR Article 5(1)(e).

      +
      + "Personal data shall be kept in a form which permits identification of data subjects for + no longer than is necessary for the purposes for which the personal data are processed." +
      +

      Maximum retention periods:

      +
      +
      Customer Data
      +
      2 years after account closure
      +
      Employee Data
      +
      7 years after employment ends
      +
      Marketing Data
      +
      1 year after last interaction
      +
      +

      Reference: GDPR Regulation (EU) 2016/679

      +
      + data.retentionPeriod > 730 AND data.type == 'PERSONAL' + FLAG_FOR_DELETION + āš ļø Warning: Personal data retention period exceeded GDPR requirements + DataManagement + UserRecords + legal_team + 2024-05-25 + GDPR + privacy + compliance + 5 + false +
      + + + ACC-006 + Multi-Factor Authentication Required + UserAccess + High + Active + +

      MFA is mandatory for privileged accounts.

      +

      Press Ctrl + Alt + M to open MFA settings.

      +

      Supported methods:

      +
        +
      • šŸ“± SMS verification
      • +
      • šŸ“§ Email OTP
      • +
      • šŸ” Authenticator app
      • +
      • šŸ”‘ Hardware token
      • +
      +

      Formula: security_score = password_strength Ɨ mfa_enabled2

      +
      + user.role IN ('admin', 'finance', 'hr') AND !session.hasMFA + REQUIRE_MFA + šŸ”’ Security Alert: Multi-factor authentication is required for this operation + AdminPanel + FinancialReports + EmployeeData + security_team + 2024-04-10 + ciso + 2024-12-01 + security + authentication + MFA + 4 + true +
      + + + SEC-007 + SQL Injection Prevention + Security + Critical + Active + +

      šŸ›”ļø Critical Security Rule

      +

      This rule detects and blocks potential SQL injection attempts.

      +

      Common injection patterns blocked:

      +
      +SELECT * FROM users WHERE id = '1' OR '1'='1'
      +DROP TABLE users; --
      +UNION SELECT * FROM passwords
      +            
      +

      Protection includes:

      +
        +
      1. Input validation - All inputs sanitized
      2. +
      3. Parameterized queries - No direct concatenation
      4. +
      5. Escape sequences - Special characters handled
      6. +
      +
      + Warning +
      High Risk Alert
      +
      +

      Updated: Now includes NoSQL injection prevention

      +
      + if (detectSQLInjection(input)) { return BLOCK; } + BLOCK_REQUEST + ā›” SECURITY VIOLATION: Potentially malicious input detected and blocked + APIEndpoints + SearchFunctions + security_team + 2024-01-20 + security + injection + SQL + 5 + true +
      + + + PERF-008 + API Rate Limiting + Performance + Medium + Deprecated + +

      This rule has been deprecated in favor of the new adaptive rate limiting system.

      +

      Previous limits were:

      + + + + + + + + + + + + + + + + + + + + + + + + + +
      TierRequests/HourBurst Limit
      Free10010
      Pro1,00050
      Enterprise10,000500
      +
      + For questions, contact:
      + API Team
      + api-support@example.com +
      + +
      + user.apiCalls > 1000 AND timeWindow == '1hour' + THROTTLE_REQUESTS + API rate limit exceeded. Please try again later + PublicAPI + api_team + 2024-02-28 + API + rate-limiting + 2 + true +
      + +
      \ No newline at end of file diff --git a/software-rules.xsd.txt b/software-rules.xsd.txt new file mode 100644 index 0000000..dd5ecdb --- /dev/null +++ b/software-rules.xsd.txt @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/xsd_xml_viewer.html b/xsd_xml_viewer.html index 54deb7c..6902ca1 100644 --- a/xsd_xml_viewer.html +++ b/xsd_xml_viewer.html @@ -128,7 +128,13 @@ .field-row { display: flex; margin: 8px 0; + padding: 8px 0; align-items: flex-start; + border-bottom: 1px dotted #e0e0e0; + } + + .field-row:last-child { + border-bottom: none; } .field-label { @@ -145,6 +151,20 @@ word-wrap: break-word; } + /* Style for multi-value fields */ + .field-value-list { + display: flex; + flex-direction: column; + gap: 8px; + } + + .field-value-item { + padding: 4px 8px; + background: #f5f5f5; + border-left: 2px solid #007bff; + border-radius: 2px; + } + .element-pair { position: relative; } @@ -412,6 +432,10 @@ background: linear-gradient(90deg, transparent, #4fc3f7, transparent); } + .field-row { + border-bottom-color: #444; + } + .field-label { color: #64b5f6; } @@ -420,6 +444,11 @@ color: #e0e0e0; } + .field-value-item { + background: #3d3d3d; + border-left-color: #4fc3f7; + } + .element-index { background: #4fc3f7; } @@ -1012,12 +1041,16 @@ const siblings = Array.from(element.children).filter(c => c.tagName === fieldName); if (siblings.length > 1) { - // For multi-value fields, combine them + // For multi-value fields, create a list const values = siblings.map(s => formatElementContent(s)).filter(v => v && v !== '(empty)'); if (values.length > 0) { + // Create a formatted list of values + const listHtml = '
      ' + + values.map(v => `
      ${v}
      `).join('') + + '
      '; fields.push({ name: fieldName, - value: values.join(', ') + value: listHtml }); } processedTags.add(fieldName); @@ -1155,124 +1188,12 @@ } function formatElementContent(element) { - let html = ''; + // Simply get the inner HTML of the element, which preserves all HTML formatting + const innerHTML = element.innerHTML; - element.childNodes.forEach(node => { - if (node.nodeType === Node.TEXT_NODE) { - html += node.textContent; - } else if (node.nodeType === Node.ELEMENT_NODE) { - // Format known tags - const tagName = node.tagName.toLowerCase(); - const content = formatElementContent(node); - - // Apply appropriate formatting based on tag - switch(tagName) { - case 'strong': - case 'b': - html += `${content}`; - break; - case 'em': - case 'i': - html += `${content}`; - break; - case 'u': - html += `${content}`; - break; - case 'del': - case 'strike': - html += `${content}`; - break; - case 'sup': - html += `${content}`; - break; - case 'sub': - html += `${content}`; - break; - case 'mark': - case 'highlight': - html += `${content}`; - break; - case 'small': - html += `${content}`; - break; - case 'code': - html += `${content}`; - break; - case 'kbd': - html += `${content}`; - break; - case 'samp': - html += `${content}`; - break; - case 'var': - html += `${content}`; - break; - case 'pre': - html += `
      ${content}
      `; - break; - case 'critical': - html += `${content}`; - break; - case 'optional': - html += `${content}`; - break; - case 'deprecated': - html += `${content}`; - break; - case 'todo': - html += `${content}`; - break; - case 'value': - html += `${content}`; - break; - case 'unit': - html += `${content}`; - break; - case 'term': - html += `${content}`; - break; - case 'acronym': - html += `${content}`; - break; - case 'version': - html += `${content}`; - break; - case 'br': - html += '
      '; - break; - case 'hr': - html += '
      '; - break; - case 'ul': - html += `
        ${content}
      `; - break; - case 'ol': - html += `
        ${content}
      `; - break; - case 'li': - html += `
    2. ${content}
    3. `; - break; - case 'blockquote': - html += `
      ${content}
      `; - break; - case 'ref': - html += `${content}`; - break; - case 'url': - html += `${content}`; - break; - case 'link': - const href = node.getAttribute('href') || '#'; - html += `${content}`; - break; - default: - // For unknown tags, just include the content - html += content; - } - } - }); - - return html || '(empty)'; + // If there's content, return it as-is (browser will handle HTML tags) + // If empty, return the (empty) indicator + return innerHTML ? innerHTML.trim() : '(empty)'; } function formatXMLElement(element) {