TheHive-Project / TheHive-Project/Cortex-Analyzers

glom: Restructuring data, the Python way

Open
#249 8 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

scope:question
Dominant language
Python
Stars
490
Forks
405
Avg merge
2d 43m
Merged PRs (30d)
8

Description

Request Type

Thoughts on using the glom library for analyzers
immagine

Description

From https://sedimental.org/
Nested data is tricky though. Reaching into deeply structured data can get you some ugly errors. Consider this simple line:

value = target.a['b']['c']

That single line can result in at least four different exceptions, each less helpful than the last:

AttributeError: 'TargetType' object has no attribute 'a'
KeyError: 'b'
TypeError: 'NoneType' object has no attribute 'getitem'
TypeError: list indices must be integers, not str

Clearly, we need our tools to catch up to our nested data.

By way of introduction, let's start off with space-age access, the classic "deep-get":
from glom import glom
target = {'galaxy': {'system': {'planet': 'jupiter'}}}
spec = 'galaxy.system.planet'
output = glom(target, spec)
# output = 'jupiter'

target is our data, be it dict, list, or any other object
spec is what we want output to be

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no files, tests, or entry points; start by reviewing the analyzer implementations and how they currently access nested data. Determine which analyzer workflows would use glom and define a concrete scope and acceptance criteria before implementation; done should include an agreed integration plan and corresponding validation.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.