Skip to content

Instantly share code, notes, and snippets.

@tfcporciuncula
tfcporciuncula / cas-auth.js
Last active January 27, 2022 21:51
CAS authentication script for OWASP Zed Attack Proxy (ZAP or ZAProxy)
/*
* This script is intended to handle CAS (http://jasig.github.io/cas) authentication via ZAP.
*
* When working with CAS, a single POST request with the credentials is not enough to trigger the authentication.
* When we GET the login page, some input values used by CAS are generated (the login ticket and some Spring Web
* Flow related parameters), and they must be included in the POST request for the authentication to work. So
* this script basically sends a GET to the login page, parses its response looking for the values generated by
* CAS, and sends a POST request with these values and the credentials.
*
* This is enough to trigger the authentication, but it's not enough to enable a successfull authenticated scan
@tfcporciuncula
tfcporciuncula / another-cas-auth.js
Last active November 26, 2015 18:01
A temporary CAS authentication script for ZAP that should work with SSO disabled
// The authenticate function is called whenever ZAP requires to authenticate for a Context for which this script
// was selected as the Authentication Method. The function should send any messages that are required to do the authentication
// and should return a message with the authenticated response.
//
// NOTE: Any message sent in the function should be obtained using the 'helper.prepareMessage()' method.
//
// Parameters:
// helper - a helper class providing useful methods: prepareMessage(), sendAndReceive(msg)
// paramsValues - the values of the parameters configured in the Session Properties -> Authentication panel.
// The paramsValues is a map, having as keys the parameters names (as returned by the getRequiredParamsNames()
@tfcporciuncula
tfcporciuncula / BooksViewModel.kt
Created July 15, 2018 04:17
mediator-live-data-gist-3
class BooksViewModel(bookDao: BookDao) : ViewModel() {
private val booksAscending = bookDao.booksAscending()
private val booksDescending = bookDao.booksDescending()
val books = MediatorLiveData<List<Book>>()
private var currentOrder = ASCENDING
init {
@tfcporciuncula
tfcporciuncula / BooksViewModel.kt
Created July 15, 2018 04:22
mediator-live-data-gist-1
class BooksViewModel(bookDao: BookDao) : ViewModel() {
// to make things simpler here, let's skip the repository layer
val books = bookDao.books()
}
@tfcporciuncula
tfcporciuncula / BooksViewModel.kt
Created July 17, 2018 17:54
mediator-live-data-gist-2
class BooksViewModel(bookDao: BookDao) : ViewModel() {
// the LiveData from Room won't be exposed to the view...
private val dbBooks = bookDao.books()
// ...because this is what we'll want to expose
val books = MediatorLiveData<List<Book>>()
private var currentOrder = ASCENDING
@tfcporciuncula
tfcporciuncula / ApplicationInjection.kt
Created August 19, 2018 10:20
ApplicationComponent-with-builder
@Singleton
@Component(modules = [YourModule::class, ThatOtherModule::class])
interface ApplicationComponent {
@Component.Builder
interface Builder {
@BindsInstance fun applicationContext(applicationContext: Context): Builder
fun build(): ApplicationComponent
}
}
@tfcporciuncula
tfcporciuncula / nope
Last active January 15, 2019 09:52
nope
/~\
|oo ) This isn't the blogpost
_\=/_ you're looking for!
___ # / _ \
/ ()\ \\//|/.\|\\
_|_____|_ \/ \_/ ||
| | === | | |\ /| ||
|_| O |_| \_ _/ #
|| O || | | |
@tfcporciuncula
tfcporciuncula / nope
Last active January 15, 2019 09:53
nope
/~\
|oo ) This isn't the blogpost
_\=/_ you're looking for!
___ # / _ \
/ ()\ \\//|/.\|\\
_|_____|_ \/ \_/ ||
| | === | | |\ /| ||
|_| O |_| \_ _/ #
|| O || | | |
@tfcporciuncula
tfcporciuncula / nope
Last active January 15, 2019 09:53
nope
/~\
|oo ) This isn't the blogpost
_\=/_ you're looking for!
___ # / _ \
/ ()\ \\//|/.\|\\
_|_____|_ \/ \_/ ||
| | === | | |\ /| ||
|_| O |_| \_ _/ #
|| O || | | |
@tfcporciuncula
tfcporciuncula / nope
Last active January 15, 2019 09:53
nope
/~\
|oo ) This isn't the blogpost
_\=/_ you're looking for!
___ # / _ \
/ ()\ \\//|/.\|\\
_|_____|_ \/ \_/ ||
| | === | | |\ /| ||
|_| O |_| \_ _/ #
|| O || | | |