Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
A Wireshark-like display filter various data formats, including Python dictionaries, lists, objects, and SQL databases.
To quickly get started follow the steps below:
First, install the package using pip:
pip3 install pydfql
Next, import the necessary module and initialize the appropriate display filter with some data.
In the example below we are initializing the ObjectDisplayFilter
with a list of objects:
from dataclasses import dataclass
from pydfql import ObjectDisplayFilter
@dataclass
class Actor:
name: list
age: dict
gender: str
actors = [
Actor(["Laurence", "Fishburne"], {"born": "1961"}, "male"),
Actor(["Keanu", "Reeves"], {"born": "1964"}, "male"),
Actor(["Joe", "Pantoliano"], {"born": "1951"}, "male"),
Actor(["Carrie-Anne", "Moss"], {"born": "1967"}, "female")
]
df = ObjectDisplayFilter(actors)
Once the display filter is initialized, you can start filtering the data using the display filter query language. For example, let's filter the actors whose birth year is after 1960:
filter_query = "age.born > 1960"
filtered_data = df.filter(filter_query)
print(list(filtered_data))
[
Actor(name=['Laurence', 'Fishburne'], age={'born': '1961'}, gender='male'),
Actor(name=['Keanu', 'Reeves'], age={'born': '1964'}, gender='male'),
Actor(name=['Carrie-Anne', 'Moss'], age={'born': '1967'}, gender='female')
]
You can also use more complex queries to filter the data. For example, let's filter male actors born between 1960 and 1964 whose names end with "e":
filter_query = "gender == male and (age.born > 1960 and age.born < 1965) and name matches .*e$"
filtered_data = df.filter(filter_query)
print(list(filtered_data))
This will output the filtered data:
[Actor(name=['Laurence', 'Fishburne'], age={'born': '1961'}, gender='male')]
Overall, PyDFQL supports a wide range of features, including:
Dictionaries
, Lists
, Objects
, SQL
==
, !=
, <=
, <
, >=
, >
, ~=
, ~
, &
and
, or
, xor
, not
in
Text
, Number
, Date & Time
, Ethernet-
, IPv4-
, IPv6-Address
Text
, Ethernet-
, IPv4-
, IPv6-Address
upper
, lower
, len
For a detailed description of the individual features check out the User Guide.
For detailed examples of how the display filter can be utilized, please refer to the following:
This project wouldn't be possible without these awesome projects:
FAQs
A Wireshark-like display filter for querying data.
We found that pydfql demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.