| 69 | |
| 70 | |
| 71 | def asciidoc(content=False, adoc=None, t='title', title=''): |
| 72 | |
| 73 | adoc = adoc + "\n" |
| 74 | output = "" |
| 75 | if t == 'title': |
| 76 | output = '== ' + content |
| 77 | elif t == 'info': |
| 78 | content = content.rstrip('.') |
| 79 | output = "\n{}.\n\n{} {} {}{}/definition.json[*this location*] {}.\n".format(content, 'NOTE: ', title, 'is a MISP object available in JSON format at https://github.com/MISP/misp-objects/blob/main/objects/', title.lower(), ' The JSON format can be freely reused in your application or automatically enabled in https://www.github.com/MISP/MISP[MISP]') |
| 80 | elif t == 'author': |
| 81 | output = '\nauthors:: {}\n'.format(' - '.join(content)) |
| 82 | elif t == 'value': |
| 83 | output = '=== ' + content |
| 84 | elif t == 'description': |
| 85 | content = content.rstrip('.') |
| 86 | output = '\n{}\n'.format(content) |
| 87 | elif t == 'attributes': |
| 88 | # output = '\n{}\n'.format |
| 89 | # output = '[cols=\",a\"]\n' |
| 90 | output = output + '|===\n' |
| 91 | output = output + '|Object attribute | MISP attribute type | Description | Disable correlation | Multiple\n' |
| 92 | adoc = adoc + output |
| 93 | for v in content['attributes']: |
| 94 | disableCorrelation = 'icon:minus[] ' |
| 95 | description = 'icon:minus[] ' |
| 96 | multiple = 'icon:minus[] ' |
| 97 | if 'disable_correlation' in content['attributes'][v]: |
| 98 | if content['attributes'][v]['disable_correlation']: |
| 99 | disableCorrelation = 'icon:check[] ' |
| 100 | if 'multiple' in content['attributes'][v]: |
| 101 | if content['attributes'][v]['multiple']: |
| 102 | multiple = 'icon:check[] ' |
| 103 | if 'description' in content['attributes'][v]: |
| 104 | if content['attributes'][v]['description']: |
| 105 | description = '{}'.format(content['attributes'][v]['description']) |
| 106 | if 'values_list' in content['attributes'][v]: |
| 107 | values = content['attributes'][v]['values_list'] |
| 108 | description = '{} {}'.format(content['attributes'][v]['description'], values) |
| 109 | if 'sane_default' in content['attributes'][v]: |
| 110 | values = content['attributes'][v]['sane_default'] |
| 111 | description = '{} {}'.format(content['attributes'][v]['description'], values) |
| 112 | output = '\n| {} | {} a| {} a| {} a| {}\n'.format(v, content['attributes'][v]['misp-attribute'], description, disableCorrelation, multiple) |
| 113 | adoc = adoc + output |
| 114 | output = '\n|===\n' |
| 115 | adoc = adoc + output |
| 116 | return adoc |
| 117 | |
| 118 | |
| 119 | adoc = "" |