0

I've managed to chop down the initial file into a final array that I want, but I'm uncertain on how to manipulate it. I have a clear before and desired "after";

Before:

[
  "Access Token Manipulation",
  "T1134",
  [
    {
      "kill_chain_name": "mitre-attack",
      "phase_name": "defense-evasion"
    },
    {
      "kill_chain_name": "mitre-attack",
      "phase_name": "privilege-escalation"
    }
  ]
]

After:

[
  "Access Token Manipulation",
  "T1134",
  "defense-evasion"
]
[
  "Access Token Manipulation",
  "T1134",
  "privilege-escalation"
]

I'll convert this with @csv afterwards, but the objects need to be split up first. Part of me thinks that recurse or a foreach works, but another part of me thinks that this is just so simple and I'm looking over something.

1 Answer 1

2

Remember the first two elements in a variable, extract the phase name and add it to the variable:

jq '[.[0],.[1]] as $h | .[2][].phase_name | $h + [.]'
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.