Skip to content

PPA Tools PPA Tools: Generate

Summary

This module contains actions used to generate various data.

Actions

ppa_tools.generate.

html_table

Generate an HTML table to use in a markdown document or email.

Minimum Plugin Version: 1.2.0

Input
  • header: a list of table column headers

  • rows: the table contents as a list of lists, where each inner list is a row of values

Output

The generated HTML table as a string.

Example
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
- ppa_tools.html.generate_table:
    header:
      - City
      - Country
    rows:
      - - Paris
        - France
      - - London
        - England
  save: html_table

ppa_tools.generate.

random_number

Generate a random number within a defined range.

Minimum Plugin Version: 8.2.0

Input
  • minimum: the smallest number in the range (defaults to 0)

  • maximum: the largest number in the range (defaults to 10)

Output

The generated number.

Example
1
2
- ppa_tools.generate.random_number:
  save: number

ppa_tools.generate.

table_from_dictionaries

Generate table data from a list of dictionaries.

Minimum Plugin Version: 1.3.0

Input
  • header: a list of table column headers

  • keys: a list of corresponding dictionary keys, one for each header

  • dictionaries: a list of dictionaries to get the values of each key from

Output

A dictionary containing the keys header & rows.

Example
  • Finding failed SSH logons using extract_values & saving them as failed_logons

  • Using this action to turn failed_logons into table data, & saving it as failed_logons_table

  • Displaying a table using the data generated by this action

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
- ppa_tools.text.extract_values:
    extract:
      - name: username
        expression: for (.*) from
      - name: ip_address
        expression: from (\d+\.\d+\.\d+\.\d+) port
    text: >
      2020-08-11T08:19:40.463248+00:00 machine-name sshd[10349]: Failed password for user_1 from 1.2.3.4 port 58041 ssh2
      2020-08-12T13:24:07.463248+00:00 machine-name sshd[10349]: Failed password for user_2 from 2.3.4.5 port 58041 ssh2
  save: failed_logons

- ppa_tools.generate.table_from_dictionaries:
    header:
      - Username
      - IP Address
    keys:
      - username
      - ip_address
  load:
    dictionaries: failed_logons
  save: failed_logons_table

- ppa.ui.output_table:
    text: Failed SSH Logons
  load:
    header: failed_logons_table.header
    rows: failed_logons_table.rows

Headers & Keys

The header & keys lists must be the same length, & the attributes must be in the same order.

If a supplied key is missing from a dictionary, its value will be blank.

ppa_tools.generate.

uuid

Generate a UUID.

Minimum Plugin Version: 8.2.0

Input

This action takes no inputs.

Output

The generated UUID as a string.

Example
1
2
- ppa_tools.generate.uuid:
  save: uuid