Skip to content
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

Common Issues #325

Open
georgedias opened this issue Nov 1, 2024 · 0 comments
Open

Common Issues #325

georgedias opened this issue Nov 1, 2024 · 0 comments

Comments

@georgedias
Copy link
Contributor

georgedias commented Nov 1, 2024

Code updates

utilities/xccfs.ts

Function removeHtmlTags() document the regex being used.
Use this code block

/**
 * Removes all the HTML tags and leaves only the text content.
  *
 * @param input - The string from which HTML tags should be removed.
 * @returns A new string with all HTML tags removed.
 * 
 * @example
 * ```typescript
 * const str = '<div>Hello <b>World</b>!</div>';
 * const stripped = removeHtmlTags(str);
 * console.log(stripped); // Output: "Hello World!"
 * ```
 */
export function removeHtmlTags(input: string): string {
  // Regex explained
  //    <: Matches the opening angle bracket of an HTML tag
  //   /?: Matches zero or one forward slash /, to include closing tags
  // [^>]: Matches any character except the > symbol
  //    +: Ensures preceding pattern ([^>]) matches one or more characters
  // (>|$):
  //   > matches the closing angle bracket of an HTML tag.
  //   $ matches the end of the string. This ensures the regex can handle
  //     cases where the tag is incomplete or unclosed (e.g., <div)
  // g: Global flag to find all matches in the input string
  return input.replace(/<\/?[^>]+(>|$)/g, '');
}

Function convertEncodedXmlIntoJson(encodedXml: string, xmlParserOption: string = 'withArrayOption'): any implement the isArray() based of the XCCDF schema

Use Abstract Syntax Tree (AST) npm Library

Implement the updates to profiles and controls using the AST-GREP npm package

Object Types Library

SpreadsheetTypes

SpreadsheetTypes is a type alias for the possible types of spreadsheets. It is used to specify the type of spreadsheet when calling functions that require this information. Currently, the possible types are 'cis', 'disa', and 'general'.

export enum SpreadsheetTypes {
   CIS = 'cis',
   DISA = 'disa',
   GENERAL = 'general'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant