Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
The argteller package provides the class and method decorators for a self-documenting, highly user-friendly interactive class object constructor. It will ask you for parameters that you need to provide, one by one. It will tell you the options that are available, and ask you for different parameters depending on what you have already provided. You can encode all of these in the custom DSL (domain specific language) script.
::
pip install argteller
To start using argteller, you must first create a DSL script, either in the form of a text file or a string value. This script contains the names of the parameters as well as other auxiliary information, which we will go over in detail.
The first two, and most basic, pieces of information are: topic
and parameter
. The name of a topic
is just a line of string. The name of a parameter
is a line of string preceded by -
. Let's look at an example:
::
person <--- topic
-height <--- parameter
-weight
-name
We will now apply this DSL script to a Python class. First we need to import the class decorator. Also, we need to put the script either as a string variable or a text file, in which case, we need the path to the file. Let's assume this variable is string
.
.. code:: python
from argteller import ArgtellerClassDecorator
@ArgtellerClassDecorator(map_str=string)
class MyClass():
def __init__(self):
print('Finally!')
my_object = MyClass()
Running the above code will parse the script into tree data structure and prompt the user for the required arguments by recursively traversing down this tree, giving appropriate prompts for the given node.
::
✔ Checking person requirements... Failed!
Required argument(s):
► height weight name
Providing an argument for one of the parameter will prompt different set of required arguments:
.. code:: python
my_object = MyClass(height=189, name='Tim')
::
✔ Checking person requirements... Failed!
Required argument(s):
► weight
You could have multiple topics:
::
person <--- topic
-height
-weight
-name
other_details <--- 2nd topic
-hobby
-major
It will check them one by one, providing the user an opportunity to partition and organize the parameters by topics:
.. code:: python
my_object = MyClass(height=189, weight=80, name='Tim',
hobby='basketball')
::
✔ Checking person requirements... Passed!
✔ Checking other_details requirements... Failed!
Required argument(s):
► major
Once you provide all the required parameters, the original __init__
method will be called.
.. code:: python
my_object = MyClass(height=189, weight=80, name='Tim',
hobby='basketball', major='math')
::
✔ Checking person requirements... Passed!
✔ Checking other_details requirements... Passed!
Finally!
At this point, all of the parameters are accessible as object fields, anywhere as if they were always there, including from within the __init__
method as well as any other instance methods.
.. code:: python
print(my_object.major)
print(my_object.name)
You can specify available options by preceding the name with a tab
and =
character:
::
person
-height
-weight
-name
other_details
-hobby
=basketball <--- available options
=soccer
-major
.. code:: python
my_object = MyClass(height=189, weight=80, name='Tim')
::
✔ Checking person requirements... Passed!
✔ Checking other_details requirements... Failed!
Required argument(s):
► hobby major
Available [ hobby ] options:
► basketball soccer
What if there is a parameter that's needed only if the hobby
is basketball
, such as style
, that could be indoor
or outdoor
?
::
person
-height
-weight
-name
other_details
-hobby
=basketball
-style <--- conditional parameter
=indoor
=outdoor
=soccer
-major
.. code:: python
my_object = MyClass(height=189, weight=80, name='Tim',
hobby='basketball')
::
✔ Checking person requirements... Passed!
✔ Checking other_details requirements... Failed!
Required argument(s):
► major
Required argument(s) for [ basketball ] hobby:
► style
Available [ style ] options:
► indoor outdoor
You could also have optional parameters, which are parameters that you can leave empty and still pass the topic requirement. For these you use +
character.
::
person
-height
-weight
-name
+gender <--- you can provide this parameter or not
other_details
-hobby
=basketball
-style
=indoor
=outdoor
=soccer
-major
.. code:: python
my_object = MyClass(height=189, weight=80, name='Tim',
hobby='basketball')
::
✔ Checking person requirements... Passed!
✔ Checking other_details requirements... Failed!
Required argument(s):
► major
Required argument(s) for [ basketball ] hobby:
► style
Available [ style ] options:
► indoor outdoor
Optional argument(s) for person:
► gender
You could have a parameter whose value is either True
or False
, and perhaps a conditional parameter depends on this boolean parameter. For these you use ?
character. For example:
::
person
-height
-weight
-name
+gender
other_details
-hobby
-major
?has_car <--- only ask for car_brand if this person has_car
-car_brand
.. code:: python
my_object = MyClass(height=189, weight=80, name='Tim',
hobby='basketball', has_car=True)
::
✔ Checking person requirements... Passed!
✔ Checking other_details requirements... Failed!
Required argument(s):
► major
Required argument(s) for [ has_car ] option:
► car_brand
Optional argument(s) for person:
► gender
You could provide example for the parameter value with explicit string values. For these you use ==
characters.
::
person
-height
-weight
-name
+gender
other_details
-hobby
-major
?has_car
-car_brand
=='Toyota', 'BMW', 'Tesla' <--- string examples of the value
.. code:: python
my_object = MyClass(height=189, weight=80, name='Tim',
hobby='basketball', has_car=True)
::
✔ Checking person requirements... Passed!
✔ Checking other_details requirements... Failed!
Required argument(s):
► major
Required argument(s) for [ has_car ] option:
► car_brand
Examples for [ car_brand ]: 'Toyota', 'BMW', 'Tesla'
Optional argument(s) for person:
► gender
Lastly, you can assign a value to a parameter depending on which available option argument was chosen:
::
person
-height
-weight
-name
+gender
other_details
-hobby
=basketball
-style
=indoor
=outdoor
=soccer
=coding
-major:'comp-sci'
-major
.. code:: python
my_object = MyClass(height=189, weight=80, name='Tim',
hobby='coding')
::
✔ Checking person requirements... Passed!
✔ Checking other_details requirements... Passed!
Optional argument(s) for person:
► gender
Finally!
This object now has comp-sci
string value assigned to major
field because we chose coding
option for the hobby
parameter:
.. code:: python
print(my_object.major) # comp-sci
In case there are too many parameters to cover under one topic, but you feel reluctant to branch it out into a separate topic, you have an option of using subtopic. The subtopic only differs in that it adds a tab.
::
main_topic
sub_topic1
-param1
-param2
sub_topic2
-param3
-param4
.. code:: python
my_object = MyClass(param1=1, param2=2)
::
✔ Checking main_topic requirements...
⮑ sub_topic1 requirements... Passed!
⮑ sub_topic2 requirements... Failed!
Required argument(s):
► param3 param4
FAQs
Decorator for stylized interactive constructor using DSL and parser.
We found that argteller 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
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.