Operations
Raider operations are pieces of code that will be executed when the HTTP response is received. The most important one is Next which controls the authentication flow. But anything can be done with the operations, and Raider allows writing custom ones in hylang to enable users to add functionality that isn’t supported by the main code.
Next
Inside the Authentication object Next is used to define the next step of the authentication process. It can also be used inside “action” attributes of the other Operations to allow conditional decision making.
(Next "login")
- class Next(next_flow)[source]
Operation defining the next flow.
Inside the Authentication object Next is used to define the next step of the authentication process. It can also be used inside “action” attributes of the other Operations to allow conditional decision making.
- next_flow
A string with the name of the next flow to be executed.
Success
Operation that will indicate that the FlowGraph has completed successfully and stop running any further. Print the optional successh message.
(Success "Login succeeded.")
- class Success(message=None)[source]
Operation that will signal a Success in the process.
- message
An optional string with the message to be printed.
Failure
Operation that will indicate that the FlowGraph has failed and stop running any further. Print the optional error message.
(Error "Login failed.")
- class Failure(message=None)[source]
Operation that will signal a Failure in the process.
- message
An optional string with the error message to be printed.
Print
When this Operation is executed, it will print each of its elements in a new line.
(Print
"This will be printed first"
access_token
"This will be printed on the third line")
(Print.body)
(Print.headers)
(Print.headers "User-agent")
(Print.cookies)
(Print.cookies "PHPSESSID")
- class Print(*args, flags=4, function=None)[source]
Operation that prints desired information.
When this Operation is executed, it will print each of its elements in a new line.
- \*args
A list of Plugins and/or strings. The plugin’s extracted values will be printed.
- __init__(*args, flags=4, function=None)[source]
Initializes the Print Operation.
- Parameters
*args (
Union
[str
,Plugin
]) – Strings or Plugin objects to be printed.
Save
When this Operation is executed, it will save its elements in a file.
(Save "/tmp/access_token" access_token)
(Save "/tmp/session" session_id :append True)
(Save.body "/tmp/body")
- class Save(filename, plugin=None, save_function=None, flags=0)[source]
Operation to save information to files.
- filename
The path to the file where the data should be saved.
- __init__(filename, plugin=None, save_function=None, flags=0)[source]
Initializes the Save operation.
- Parameters
filename (
str
) – The path of the file where data should be saved.plugin (
Optional
[Plugin
]) – If saving Plugin’s value, this should contain the plugin.save_function (
Optional
[Callable
[...
,None
]]) – A function to use when writing the file. Use when needing some more complex saving instructions.flags (
int
) – Operation’s flags. No flag is set by default. Set WILL_APPEND if needed to append to file instead of overwrite.
- save_to_file(content)[source]
Saves a string or plugin’s content to a file.
Given the content (a string or a plugin), open the file and write its contents. If WILL_APPEND was set, append to file instead of overwrite.
- Parameters
content (
Union
[str
,Plugin
,Response
]) – A string or a Plugin with the data to be written.- Return type
None
- classmethod body(filename, append=False)[source]
Save the entire HTTP body.
If you need to save the entire body instead of extracting some data from it using plugins, use
Save.body
. Given a filename, and optionally a booleanappend
, write the body’s contents into the file.- Parameters
filename (
str
) – The path to the file where to write the data.append (
bool
) – A boolean which when True, will append to existing file instead of overwriting it.
- Return type
- Returns
A Save object which will save the response body.
Http
(Http
:status 200
:action
(Next "login")
:otherwise
(Next "multi_factor"))
- class Http(status, action, otherwise=None)[source]
Operation that runs actions depending on the HTTP status code.
A Http object will check if the HTTP response status code matches the code defined in its “status” attribute, and run the Operation inside “action” if it matches or the one inside “otherwise” if not matching.
- status
An integer with the HTTP status code to be checked.
- action
An Operation that will be executed if the status code matches.
- otherwise
An Operation that will be executed if the status code doesn’t match.
- __init__(status, action, otherwise=None)[source]
Initializes the Http Operation.
- Parameters
status (
int
) – An integer with the HTTP response status code.action (
Union
[Operation
,List
[Operation
],None
]) – An Operation object to be run if the defined status matches the response status code.otherwise (
Union
[Operation
,List
[Operation
],None
]) – An Operation object to be run if the defined status doesn’t match the response status code.
Grep
(Grep
:regex "TWO_FA_REQUIRED"
:action
(Next "multi_factor")
:otherwise
(Print "Logged in successfully"))
- class Grep(regex, action, otherwise=None)[source]
Operation that runs actions depending on Regex matches.
A Grep object will check if the HTTP response body matches the regex defined in its “regex” attribute, and run the Operation inside “action” if it matches or the one inside “otherwise” if not matching.
- regex
A string with the regular expression to be checked.
- action
An Operation that will be executed if the status code matches.
- otherwise
An Operation that will be executed if the status code doesn’t match.