Skip to content

Instantly share code, notes, and snippets.

@tdgunes
Created February 3, 2020 16:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tdgunes/4a62924cb22b68703e1e00630345121f to your computer and use it in GitHub Desktop.
Save tdgunes/4a62924cb22b68703e1e00630345121f to your computer and use it in GitHub Desktop.
Replaces dots in a json for preprocessing data for MongoDB
import re
if __name__ == '__main__':
TEST = """
[
{
"_id": "5e1d995f08f9e94ea4c67e31",
"data.Attack_Pattern_Catalog.Attack_Patterns.Attack_Pattern": [
{
"_attributes": {
"ID": "1",
"N.ame": "Accessing Functionality Not Properly Constrained by ACLs",
"Ab.straction": "Standard",
"Status": "Draft"
},
"Description" : {
"_text": "In applications, particularly web applications, access to functionality is mitigated by an authorization framework. This framework maps Access Control Lists (ACLs) to elements of the application's functionality; particularly URL's for web apps. In the case that the administrator failed to specify an ACL for a particular element, an attacker may be able to access it with impunity. An attacker with the ability to access functionality not properly constrained by ACLs can obtain sensitive information and possibly compromise the entire application. Such an attacker can access resources that must be available only to users at a higher privilege level, can access management sections of the application, or can run queries for data that they otherwise not supposed to."
},
"Likelihood_Of_Attack": {
"_text": "High"
"""
for line in TEST.splitlines():
s = re.sub(r'"(.*\..*)" *:', lambda x: x.group(0).replace(".", "#"), line)
print(s)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment