### Python Package Installation Order Configuration Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/documentation/app_file_structure/source_dependencies.md Example ordering.txt file content for specifying Python package installation sequence. The file must use UNIX line endings and list package filenames in installation order. ```txt pytz-2020.1-py2.py3-none-any.whl Babel-2.8.0-py2.py3-none-any.whl speaklater-1.3.tar.gz Flask-Babel-1.0.0.tar.gz ``` -------------------------------- ### Example NPM package.json Structure - JSON Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/tutorials/installing_nodejs_as_a_source_dependency.md Shows an example 'package.json' configuration for the NodeJS app, with values for name, description, and entry point. Dependency: Must be created and present for NPM to manage dependencies. Limitations: This is an example and may require editing for actual deployment. ```json { "name": "nodejs_app",' "version": "1.0.0", "description": "App that uses NodeJS and an Express server", "main": "server.js", "author": "IBM", "license": "" } ``` -------------------------------- ### Initializing NPM Project (Bash) Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/tutorials/qjslib_javascript_library.md Runs the `npm init` command to start the Node Package Manager setup process. This interactively prompts for project details (name, version, description, etc.) and creates a `package.json` file to manage project metadata and dependencies. ```bash npm init ``` -------------------------------- ### RPM Installation Order Configuration Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/documentation/app_file_structure/source_dependencies.md Example ordering.txt file content for specifying RHEL 8 RPM installation sequence. The file must use UNIX line endings and list RPM filenames in installation order. ```txt nginx-1.17.8-1.el8.ngx.x86_64.rpm nodejs-10.19.0-1.module+el8.1.0+5726+6ed65f8c.x86_64.rpm npm-6.13.4-1.10.19.0.1.module+el8.1.0+5726+6ed65f8c.x86_64.rpm ``` -------------------------------- ### Creating and Navigating Project Directory with Bash Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/tutorials/encryption_using_qpylib_encdec.md This Bash snippet demonstrates how to create a new directory for the app, 'VulnerabilitiesApp', and immediately enter it. It is a fundamental project setup step prior to any further initialization and assumes Bash is installed and available in the user's environment. No arguments or outputs are required; it simply prepares the app workspace. ```bash mkdir VulnerabilitiesApp && cd VulnerabilitiesApp ``` -------------------------------- ### Initializing QRadar App with SDK Command (Bash) Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/tutorials/encryption_using_qpylib_encdec.md This Bash command uses the QRadar App SDK to scaffold (initialize) the new app inside the current directory. Prerequisites include having the SDK installed and configured. The command launches an interactive setup for initializing the codebase. There are no arguments, but certain values may be prompted interactively. The output is a set of template app files. ```bash qapp create ``` -------------------------------- ### Launching the React Application Locally - Bash Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/tutorials/using_react_and_carbon_components.md This snippet starts the development server for the React application, making it available at http://localhost:3000/. It assumes you are in the 'react-ui' directory with all node modules installed. ```bash yarn start ``` -------------------------------- ### Running the QRadar App SDK Installation Script (Bash) Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/tutorials/installing_the_qradar_app_sdk.md This command executes the `install.sh` script located in the current directory to install the IBM QRadar App SDK. It must be run from the directory where the SDK archive was extracted. The script installs the SDK, typically in the user's home directory (`~/qradarappsdk`), and does not require sudo privileges. ```bash ./install.sh ``` -------------------------------- ### Implementing NodeJS Express Server Endpoints - JavaScript Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/tutorials/installing_nodejs_as_a_source_dependency.md Implements a basic Express server with two GET endpoints ('/index' and '/debug') that respond with static text, and listens on port 5000. Dependency: express must be installed and required runtime environment. Input: HTTP GET requests; Output: Replies with 'Hello World!' or 'Pong!'. Limitations: No authentication and minimal error handling. ```javascript const express = require('express') const app = express() app.get('/index', (req, res) => res.send('Hello World!')) app.get('/debug', (req, res) => res.send('Pong!')) app.listen(5000, () => console.log('Server running on port 5000!')) ``` -------------------------------- ### Installing Carbon and Supporting Dependencies in React App - Bash Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/tutorials/using_react_and_carbon_components.md This set of commands installs Carbon React components, IBM Security Carbon extensions, Carbon colors, Carbon icons, and node-sass into the React app. It also installs 'axios' for promise-based HTTP requests. All commands are to be run from within the 'react-ui' directory, and require a working Node.js/npm/yarn setup. ```bash yarn add carbon-components-react @carbon/ibm-security @carbon/colors @carbon/icons-react ``` ```bash yarn add node-sass ``` ```bash yarn add axios ``` -------------------------------- ### Packaging and Deploying QRadar App with SDK - Bash Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/tutorials/installing_nodejs_as_a_source_dependency.md Builds and deploys the QRadar app package using SDK commands: 'qapp package' for packaging, then 'qapp deploy' for deployment. Input: App files prepared, required parameters for package and deploy specified. Output: Packaged and optionally deployed app to QRadar environment. Dependencies: Correct SDK setup and network connectivity to QRadar. ```bash qapp package -p <_app zip name_> qapp deploy -p <_app zip name_> -q -u <_qradar user_> ``` -------------------------------- ### Creating Build Setup Script in Bash Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/tutorials/replacing_flask_with_nginx.md Sets up a build-time script to create the `/opt/app-root/tmp` directory for storing NGINX temporary files. Required to ensure correct operation of the app during runtime. ```bash mkdir -p container/build ``` ```bash #!/bin/bash mkdir -p /opt/app-root/tmp ``` ```txt /opt/app-root/container/build/build.sh ``` -------------------------------- ### Configuring NGINX with Supervisor in Configuration File Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/tutorials/replacing_flask_with_nginx.md Sets up Supervisor configuration for managing the NGINX process. Automatically starts and restarts the process as needed, and logs output to specified files. Requires directory setup for Supervisor configurations. ```bash mkdir -p container/conf/supervisord.d ``` ```conf [program:nginx] command=/usr/sbin/nginx -c /opt/app-root/container/conf/nginx/nginx.conf directory=/opt/app-root/app autostart=true autorestart=true stderr_logfile=/opt/app-root/store/log/nginx.log stdout_logfile=/opt/app-root/store/log/nginx.log ``` -------------------------------- ### Initializing NPM Package Configuration - Bash Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/tutorials/installing_nodejs_as_a_source_dependency.md Runs 'npm init' to create a new 'package.json' using prompts for NodeJS dependency management. Dependency: NodeJS and NPM installed. Input: User answers questions; Output: 'package.json' in app folder. ```bash npm init ``` -------------------------------- ### Running the App Locally with QRadar App SDK - Bash Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/tutorials/installing_nodejs_as_a_source_dependency.md Runs the QRadar app locally using the SDK's 'qapp run' command. Requires all previous setup to be complete. Output: Local test server for the app. ```bash qapp run ``` -------------------------------- ### Viewing App SDK Documentation Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/documentation/app_editor_to_sdk_migration.md Command to view the documentation for the QRadar App SDK after installation. ```bash qapp -d ``` -------------------------------- ### Initializing QRadar App Code - Bash Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/tutorials/installing_nodejs_as_a_source_dependency.md Initializes the QRadar app code structure using the App SDK command-line tool. Requires QRadar App SDK v2 to be installed. Input: Execution in the app directory. Output: Project structure and default files for the QRadar app. ```bash qapp create ``` -------------------------------- ### Creating Project Directory for NPM App Example (Bash) Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/tutorials/qjslib_javascript_library.md Creates a new directory named 'QJSLibNPM' and changes the current working directory into it. This sets up the project folder for the QJSLib NPM/Webpack tutorial. ```bash mkdir QJSLibNPM && cd QJSLibNPM ``` -------------------------------- ### Runtime Certificate Update Configuration Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/documentation/app_file_structure/build_and_runtime_dependencies.md Example ordering.txt content for runtime configuration showing how to update CA certificates during container startup. Uses as_root command to execute with elevated privileges. ```txt as_root ${APP_ROOT}/bin/update_ca_bundle.sh ``` -------------------------------- ### Listing All Installed RPM Packages in Bash Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/documentation/qradar_app_base_image_4.0.6_packages.md Uses the 'rpm -qa' command to query the RPM package manager database and list all installed packages. The output of this command forms the basis for the package list presented in the document. ```bash rpm -qa ``` -------------------------------- ### Generating React Application with Create React App - Bash Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/tutorials/using_react_and_carbon_components.md This command uses npx to bootstrap a React application inside a 'react-ui' subfolder, required for building the app's frontend. It requires npm 5.2+ and Node.js installed; it installs all default dependencies for development. ```bash npx create-react-app react-ui ``` -------------------------------- ### Initializing Flask Replacing App with QRadar SDK (Bash) Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/tutorials/using_named_services.md Uses the `qapp create` command from the QRadar app SDK v2 to scaffold the application structure within the `NamedServiceCommandAndPort` directory for the third example. ```bash qapp create ``` -------------------------------- ### Folder Setup and Navigation in Bash Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/tutorials/replacing_flask_with_gunicorn.md The snippet demonstrates creating a directory for the Gunicorn app and changing into that directory. Prerequisites include basic knowledge of Bash command-line operations. ```bash mkdir GunicornApp && cd GunicornApp ``` -------------------------------- ### Create and Initialize QRadar App Directory - Bash Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/tutorials/getting_available_api_versions.md Initializes a new QRadar app directory, naming it 'APIVersion', and switches to this directory. This is a prerequisite setup step for building the QRadar app. ```bash mkdir APIVersion && cd APIVersion ``` -------------------------------- ### Packaging and Deploying the QRadar App (Bash) Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/tutorials/supporting_multi_tenancy.md Provides the QRadar App SDK commands to package the application into a zip file (`qapp package`) and then deploy it to a specified QRadar console (`qapp deploy`). Requires replacing placeholders like ``, ``, and `` with actual values. Requires QRadar App SDK v2 and access credentials for the target QRadar console. ```bash qapp package -p qapp deploy -p -q -q ``` -------------------------------- ### Bootstrapping QRadar App Project Structure - Bash Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/tutorials/using_sqlite.md Initializes the QRadar app's base structure using the QRadar App SDK tool. Runs the 'qapp create' command to generate necessary boilerplate files. Require QRadar App SDK v2 installed. ```bash qapp create ``` -------------------------------- ### Implementing Client-Side Logic with Browser QJSLib (JavaScript) Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/tutorials/qjslib_javascript_library.md JavaScript code (`app/static/main.js`) for the browser app example. It accesses QJSLib from the global `window.qappfw` object, retrieves HTML elements, uses `QRadar.fetch` to get installed applications via the QRadar API, gets the current user with `QRadar.getCurrentUser()`, and updates the HTML content accordingly. Assumes QJSLib is loaded via a script tag. ```javascript const QRadar = window.qappfw.QRadar; const loadField = document.getElementById("qjslib-load-status"); const currentUserField = document.getElementById("current-user"); const installedAppsList = document.getElementById("installed-apps"); QRadar.fetch("/api/gui_app_framework/applications") .then(function(response) { return response.json() }) .then(function(apps) { for (const app of apps) { const appItem = document.createElement('li'); appItem.appendChild(document.createTextNode(app.manifest.name)); installedAppsList.appendChild(appItem); } }) .catch(function(error) { alert(error) }); const currentUser = QRadar.getCurrentUser() currentUserField.innerText = currentUser.username; loadField.innerText = "QJSLib loaded successfully" ``` -------------------------------- ### Managing Application Instances Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/documentation/gui_application_framework_rest_endpoints.md GET endpoint to retrieve list of application instances installed on QRadar with their manifest JSON structures and status. ```REST GET /gui_app_framework/applications ``` -------------------------------- ### Packaging and Deploying QRadar App Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/tutorials/using_react_and_carbon_components.md Commands for building, packaging, and deploying the application to a QRadar console instance. ```bash cd react-ui && yarn build cd .. zip app.zip -r app container manifest.json qapp deploy -p app.zip -q -u ``` -------------------------------- ### Managing Application Definitions Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/documentation/gui_application_framework_rest_endpoints.md GET endpoint to retrieve list of installed application definitions including manifest JSON structures and status. ```REST GET /gui_app_framework/application_definitions ``` -------------------------------- ### Creating Project Directory for Browser App Example (Bash) Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/tutorials/qjslib_javascript_library.md Creates a new directory named 'QJSLibBrowser' and changes the current working directory into it. This sets up the project folder for the QJSLib browser import tutorial. ```bash mkdir QJSLibBrowser && cd QJSLibBrowser ``` -------------------------------- ### Installing Python Packages Using pip2tgz Command Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/documentation/app_file_structure/source_dependencies.md Command for downloading Python packages and their dependencies into a target directory using pip2pi tool. The command allows specifying package versions using the == syntax. ```bash pip2tgz ``` ```bash pip2tgz python_packages/pytest/ pytest==2.8.2 ``` -------------------------------- ### Registering Startup Script - Plaintext Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/tutorials/using_sqlite.md Defines execution order for app startup scripts by listing their absolute path. This file is read at app launch to run the defined script(s) in sequence. Required format: each script path on a new line. ```txt /opt/app-root/container/run/startup.sh ``` -------------------------------- ### Initializing Flask App and DB with Configuration - Python Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/tutorials/using_sqlite.md Initializes the Flask web application, loads runtime config from JSON, registers additional routes, sets cookies, customizes response headers, and executes code to ensure the SQLite database and schema are ready before first request. Dependencies: flask, qpylib, custom database helpers. Inputs: configuration file, schema path. Outputs: ready-to-serve Flask app instance. Must be invoked as factory method in QRadar app entrypoint. ```python __author__ = 'IBM' import json from .db.database import create_db, execute_schema_sql from flask import Flask from qpylib import qpylib # Flask application factory. def create_app(): # Create a Flask instance. qflask = Flask(__name__) # Retrieve QRadar app id. qradar_app_id = qpylib.get_app_id() # Create unique session cookie name for this app. qflask.config['SESSION_COOKIE_NAME'] = 'session_{0}'.format(qradar_app_id) # Initialize database settings and flask configuration options via json file with open(qpylib.get_root_path( "container/conf/config.json")) as config_json_file: config_json = json.load(config_json_file) qflask.config.update(config_json) # Hide server details in endpoint responses. # pylint: disable=unused-variable @qflask.after_request def obscure_server_header(resp): resp.headers['Server'] = 'QRadar App {0}'.format(qradar_app_id) return resp # Register q_url_for function for use with Jinja2 templates. qflask.add_template_global(qpylib.q_url_for, 'q_url_for') # Initialize logging. qpylib.create_log() # To enable app health checking, the QRadar App Framework # requires every Flask app to define a /debug endpoint. # The endpoint function should contain a trivial implementation # that returns a simple confirmation response message. @qflask.route('/debug') def debug(): return 'Pong!' # Import additional endpoints. # For more information see: # https://flask.palletsprojects.com/en/1.1.x/tutorial/views from . import views qflask.register_blueprint(views.viewsbp) # create db by loading schema db_name = qflask.config["DB_NAME"] schema_file_path = qpylib.get_root_path("container/conf/db/schema.sql") create_db(db_name) execute_schema_sql(db_name, schema_file_path) return qflask ``` -------------------------------- ### Running QRadar App Locally Using SDK in Bash Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/tutorials/adding_csrf_protection.md This Bash command invokes 'qapp run' to start the QRadar app locally for testing. It depends on a properly configured 'qenv.ini' and pre-built application code, and the QRadar App SDK must be installed and available in the environment. ```bash qapp run ``` -------------------------------- ### Initializing QRadar App Structure using SDK (Bash) Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/tutorials/supporting_multi_tenancy.md Uses the QRadar App SDK v2 `qapp create` command to generate the basic file structure and boilerplate code for a new QRadar application within the current directory. Requires the QRadar App SDK v2 to be installed and configured. ```bash qapp create ``` -------------------------------- ### Installing Flask Using pip Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/tutorials/developing_apps_in_eclipse.md This command is used to install Flask, a popular web framework for Python, into the local site-packages library using pip, if it is not already installed. ```bash python -m pip install Flask ``` -------------------------------- ### Accessing SDK Documentation Command for QRadar App Framework v2.1.0+ Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/documentation/qradar_app_sdk_overview.md Command to view the documentation for the QRadar App Framework SDK version 2.1.0 and later. This command displays the documentation after the SDK has been installed. ```bash qapp -d ``` -------------------------------- ### Building and Running QRadar App Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/tutorials/using_react_and_carbon_components.md Commands for building the React app and running it in the QRadar development environment. ```bash cd react-ui && yarn build cd .. qapp clean -i qapp run ``` -------------------------------- ### Installing Express as Dev Dependency - Bash Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/tutorials/installing_nodejs_as_a_source_dependency.md Installs the Express package as a dev dependency into the app using npm. Requires internet and a valid 'package.json'. Input: 'npm install' command; Output: express added to dependencies and 'node_modules' created or updated. ```bash npm install --save-dev express ``` -------------------------------- ### Configuring Build-time Dependencies in QRadar App Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/documentation/app_file_structure/build_and_runtime_dependencies.md Example ordering.txt file for build-time configuration showing how to execute a deployment script during container build. The file specifies commands to run in order during the docker build process. ```txt /opt/app-root/container/build/deploy.sh ``` -------------------------------- ### Creating and Navigating App Directory - Bash Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/tutorials/installing_nodejs_as_a_source_dependency.md Creates a new directory for the NodeJS app and navigates into it using bash commands. No dependencies beyond a standard UNIX shell. Input: None or current working directory. Output: A new folder 'NodeJSApp' and changed working directory. ```bash mkdir NodeJSApp && cd NodeJSApp ``` -------------------------------- ### Creating App Run Directory for Startup Scripts - Bash Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/tutorials/using_sqlite.md Sets up the 'container/run' directory to store the app's startup scripts. This directory is later referenced to guarantee startup tasks, such as DB path creation, can execute reliably. ```bash mkdir -p container/run ``` -------------------------------- ### Defining RPM Install Order for QRadar - TXT Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/tutorials/installing_nodejs_as_a_source_dependency.md Lists the RPM package filenames for QRadar to install when building the app container. Prerequisite: RPM files must already exist at specified locations. No dependencies beyond correct file naming. ```txt nodejs-10.21.0-3.module+el8.2.0+7071+d2377ea3.x86_64.rpm npm-6.14.4-1.10.21.0.3.module+el8.2.0+7071+d2377ea3.x86_64.rpm ``` -------------------------------- ### Deploying the QRadar App - Bash Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/tutorials/handling_app_certificates.md Deploys the previously packaged QRadar app using the 'qapp' cli tool. Requires package filename, QRadar console, and QRadar user credentials as parameters (placeholders included). Input: app zip file, QRadar instance connection details. Output: app deployed to designated QRadar instance. ```bash qapp deploy -p <_app zip name_> -q <_qradar console_> -q <_qradar user_> ``` -------------------------------- ### Querying RPM Packages in Linux Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/documentation/qradar_app_base_image_3.0.5_packages.md Command used to list all installed RPM packages on the system. This command queries the RPM database and shows all installed packages. ```bash rpm -qa ``` -------------------------------- ### Installing QPyLib Using pip Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/tutorials/developing_apps_in_eclipse.md This snippet illustrates how to install a downloaded .tar.gz package of QPyLib using pip. It is essential for integrating QPyLib into the Python development environment within Eclipse. ```bash QPYLIB_VERSION=2.0.1 python -m pip install qpylib-${QPYLIB_VERSION}.tar.gz ``` -------------------------------- ### Deleting QRadar App with SDK Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/tutorials/using_uninstall_hooks.md Command to delete the previously installed app using the SDK. Requires console address, user, and the app ID from the installation. ```bash qapp delete -q -u -a ``` -------------------------------- ### Defining Startup Script Execution Order in Text Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/tutorials/running_commands_as_root.md This text file (`container/run/ordering.txt`) specifies the scripts to be executed at application startup and their order. It lists the path to the `add_user.sh` script, ensuring it runs when the QRadar app container starts. ```text /opt/app-root/container/run/add_user.sh ``` -------------------------------- ### Packaging and Deploying a QRadar App Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/tutorials/qjslib_javascript_library.md These bash commands demonstrate how to package a QRadar app into a zip file and deploy it to a QRadar console. The first command builds and packages the app, while the second deploys it to a specific QRadar instance with authentication. ```bash npm run build && qapp package -p qapp deploy -p -q -q ``` -------------------------------- ### Exporting QRadar App as Extension Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/tutorials/using_uninstall_hooks.md Command to use the content management export tool to generate an extension from the installed app. Requires the app ID from the installation process. ```bash /opt/qradar/bin/contentManagement.pl -a export -c installed_application -i ``` -------------------------------- ### Installing QJSLib via NPM (Bash) Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/tutorials/qjslib_javascript_library.md Uses the Node Package Manager (NPM) to install the `qjslib` package as a project dependency. This downloads the library and adds it to the `dependencies` section of the `package.json` file. ```bash npm install qjslib ``` -------------------------------- ### Creating QRadar Application using qapp CLI - Bash Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/tutorials/using_react_and_carbon_components.md This snippet demonstrates how to initialize a new QRadar application using the qapp CLI tool provided by the QRadar App SDK. Running this command in an empty directory scaffolds a Docker-friendly Flask app for local and deployment usage. The only prerequisite is the QRadar App SDK installed globally. ```bash qapp create ``` -------------------------------- ### Creating Ordering File for RPMs Bash Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/tutorials/rpm_python_module_best_practices.md Creates a file named 'ordering.txt' in the 'container/rpm' directory to specify the order of installing downloaded RPMs. It ensures QRadar installs RPMs correctly by listing nodejs and npm RPM filenames. ```bash nodejs-10.21.0-3.module+el8.2.0+7071+d2377ea3.x86_64.rpm npm-6.14.4-1.10.21.0.3.module+el8.2.0+7071+d2377ea3.x86_64.rpm ``` -------------------------------- ### Installing Webpack Development Dependencies via NPM (Bash) Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/tutorials/qjslib_javascript_library.md Uses NPM to install `webpack` and `webpack-cli` as development dependencies (`--save-dev`). These tools are used to bundle JavaScript modules, including QJSLib, into a single file for deployment. ```bash npm install webpack webpack-cli --save-dev ``` -------------------------------- ### Packaging and Deploying Browser App with SDK (Bash) Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/tutorials/qjslib_javascript_library.md Commands using the QRadar App SDK to package the application into a deployable zip file (`qapp package`) and then deploy it to a specified QRadar console (`qapp deploy`). Replace placeholders like ``, ``, and `` with actual values. ```bash qapp package -p qapp deploy -p -q -q ``` -------------------------------- ### JavaScript Function for HTTP GET Requests in QRadar App Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/tutorials/performing_ariel_queries_using_qpylib.md This JavaScript code defines a function for making HTTP GET requests to Flask endpoints in the QRadar app, using QRadar's fetch API to handle CSRF tokens automatically. ```javascript const QRadar = window.qappfw.QRadar; /** * HTTP GET request to Flask endpoints * @param {string} inputID - input to read for any parameter to attach * @param {string} endpoint - the Flask endpoint to send the request to */ function request(inputID, endpoint) { // Parameter is initially set as empty string var param = ''; if (inputID) { // If there is an inputID provided // Extract the parameter from the input param = document.getElementById(inputID).value; } // Each search box has its own response box to show the output of each response let response_div = document.getElementById('response_' + inputID.split('_')[0]); response_div.style.display = 'block'; // Insert loading text while waiting for the response response_div.children[1].innerText = 'Loading ...'; // Use QRadar's fetch API to send requests, by using QRadar.fetch, // QRadar takes care of inserting the appropriate headers (such as CSRF) for you. QRadar.fetch(endpoint + param, { method: "get" }) // If the request was successful use response.json() to retreive the body of the request as JSON .then(function(response) { return response.json() }) // Update the response box with the output of the response .then(function(response) { response_div.children[1].innerText = JSON.stringify(response, null, 4) }) } ``` -------------------------------- ### Initializing QRadar App Workspace - Bash Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/tutorials/using_sqlite.md Creates the base directory for the new QRadar app and changes into it. This sets up the workspace for subsequent project initialization and development. Prerequisite: Bash shell. ```bash mkdir SQLiteApp && cd SQLiteApp ``` -------------------------------- ### Listing Installed RPM Packages using rpm in Bash Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/documentation/qradar_app_base_image_3.0.9_packages.md This command uses the Red Hat Package Manager (`rpm`) with the `-qa` flags to query (`q`) and list all (`a`) installed RPM packages on the system. It is used in this context to generate the list of packages for QRadar App Framework version 3.0.9. ```bash rpm -qa ``` -------------------------------- ### Packaging the QRadar App - Bash Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/tutorials/handling_app_certificates.md Packages the QRadar app using the 'qapp' cli tool, producing a deployable zip archive. Requires 'qapp' and a name for the zip package to be created. Input: name of zip file (placeholder). Output: new app package zip file. ```bash qapp package -p <_app zip name_> ``` -------------------------------- ### Initializing QRadar App with SDK (Bash) Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/tutorials/qjslib_javascript_library.md Uses the QRadar App SDK v2 command-line tool `qapp` to create the basic file structure and boilerplate code for a new QRadar application within the current directory. ```bash qapp create ``` -------------------------------- ### Example Uninstall Hook Failure Warning Message (Text) Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/documentation/uninstall_hooks.md This text snippet provides an example of the warning message returned by the QRadar app uninstall API when an uninstall hook fails or is skipped (e.g., if initiated by a non-ConfigServices user). The message indicates which hook failed and advises checking server logs for details. ```txt An error occurred while deleting app instance 1102. App uninstall hooks failed: Uninstall hook for my app. See server logs for more details. ``` -------------------------------- ### Querying All Installed RPM Packages in Bash Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/documentation/qradar_app_base_image_2.1.23_packages.md The 'rpm -qa' command is executed in a Bash shell to query the RPM package manager database and list all installed packages on the system. The '-q' flag specifies query mode, and '-a' specifies all packages. The output of this command is used to generate the comparison table of package versions. ```bash rpm -qa ``` -------------------------------- ### Creating Project Directory for Multi-Tenant App (Bash) Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/tutorials/supporting_multi_tenancy.md Creates a new directory named `MultitenancyMultipleInstance` for the application and changes the current working directory into it. This is the initial setup step for organizing the app's files. ```bash mkdir MultitenancyMultipleInstance && cd MultitenancyMultipleInstance ``` -------------------------------- ### Initializing NGINX App Workspace using QRadar SDK in Bash Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/tutorials/replacing_flask_with_nginx.md Creates a new directory for the NGINX app and initializes it using the QRadar app SDK. Prerequisites include having QRadar app SDK and Docker installed. The created directory will house all app-related code and configurations. ```bash mkdir NginxApp && cd NginxApp ``` ```bash qapp create ``` -------------------------------- ### Defining NPM App HTML Structure (HTML) Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/tutorials/qjslib_javascript_library.md Basic HTML file (`app/templates/index.html`) for the NPM/Webpack app example. Similar to the browser example, it includes placeholders for dynamic content. However, it only includes one script tag (`static/main.js`), which points to the JavaScript file bundled by Webpack containing both the application code and the QJSLib dependency. ```html QJSLib as an NPM package

QJSLib as an NPM package

QJSLib not loaded

Currently logged in as:

Installed apps:

    ``` -------------------------------- ### Fetching NPM Dependencies into Node Modules - Bash Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/tutorials/installing_nodejs_as_a_source_dependency.md Changes into the 'app' directory and installs NPM dependencies locally, ensuring all required NodeJS modules are available for offline app operation. Dependency: package.json and NPM. Input: current directory structure. Output: Populated 'node_modules' folder. ```bash cd app && npm install && cd .. ``` -------------------------------- ### Startup Script Ordering for Certificate Import - TXT Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/tutorials/handling_app_certificates.md Specifies the script to be executed at app startup for importing custom certificates. Used inside the file 'container/run/ordering.txt'. QRadar uses this to determine which startup scripts to execute. Input: path to startup script. Output: causes import_certs.sh to be run at app startup. ```txt /opt/app-root/container/run/import_certs.sh ``` -------------------------------- ### Downloading NodeJS and NPM RPMs with Docker - Bash Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/tutorials/installing_nodejs_as_a_source_dependency.md Uses Docker to run a RHEL UBI 8 container to download specific NodeJS and NPM RPM packages into a mapped directory. Requires Docker installed and internet access. Input: None directly. Output: NodeJS and NPM RPM files stored in 'container/rpm'. ```bash docker run \ -v $(pwd)/container/rpm:/rpm \ registry.access.redhat.com/ubi8/ubi \ yum download nodejs-10.21.0 npm-6.14.4 --downloaddir=/rpm ``` -------------------------------- ### Package and Deploy QRadar App - Bash Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/tutorials/getting_available_api_versions.md Illustrates packaging the QRadar app into a zip file and deploying it to a QRadar system. These actions are performed using the QRadar App SDK with `qapp package` and `qapp deploy` commands, requiring the app name, QRadar console, and user credentials. ```bash qapp package -p <_app zip name_> qapp deploy -p <_app zip name_> -q <_qradar console_> -u <_qradar user_> ``` -------------------------------- ### Configuring Named Service for Fragments Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/documentation/named_services.md JSON configuration for using named services with UI fragments. ```json "fragments": [ { "app_name": "SEM", "page_id": "OffenseList", "location": "header", "rest_endpoint": "/custom_endpoint", "named_service": "custom_named_service" } ] ``` -------------------------------- ### Defining Browser App HTML Structure (HTML) Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/tutorials/qjslib_javascript_library.md Basic HTML file (`app/templates/index.html`) for the browser app example. It includes placeholders (like 'qjslib-load-status', 'current-user', 'installed-apps') that will be populated by JavaScript using QJSLib. It also includes script tags to load the QJSLib library (`qappfw.min.js`) and the application's main JavaScript file (`main.js`). ```html QJSLib as a browser import

    QJSLib as a browser import

    QJSLib not loaded

    Currently logged in as:

    Installed apps:

      ``` -------------------------------- ### Downloading Flask-WTF and WTForms Dependencies Using Docker in Bash Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/tutorials/adding_csrf_protection.md This Bash command uses Docker to run a RHEL UBI 8 Python 3.8 container and downloads the Flask-WTF and WTForms packages into the app's pip directory, ensuring QRadar can install these Python dependencies. It is necessary to have Docker installed, and the required image will be pulled if not present. The '--no-deps' flag avoids downloading dependencies recursively. ```bash docker run \ -v $(pwd)/container/pip:/opt/app-root/pip \ registry.access.redhat.com/ubi8/python-38 \ pip download Flask-WTF WTForms --no-deps --dest /opt/app-root/pip ``` -------------------------------- ### Removing and Creating App Directory - Bash Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/tutorials/installing_nodejs_as_a_source_dependency.md Deletes existing 'app/' directory and recreates it as empty, then navigates into it. Requires a UNIX shell. Input: An existing or non-existing 'app' directory. Output: Reinitialized empty 'app' folder. ```bash rm -r app/ && mkdir app/ && cd app/ ``` -------------------------------- ### Configuring Named Service for Page Scripts Source: https://github.com/ibmsecuritydocs/qradar_appfw_v2/blob/main/docs/documentation/named_services.md JSON configuration for loading page scripts through named services. ```json "page_scripts": [ { "app_name": "SEM", "page_id": "OffenseList", "scripts": [ "/static/js/script_1.js", "/static/js/script_2.js" ], "named_service": "custom_named_service" } ] ```