Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement API for accessing module outputs in Go library #177

Open
xorhex opened this issue Aug 13, 2024 · 1 comment
Open

Implement API for accessing module outputs in Go library #177

xorhex opened this issue Aug 13, 2024 · 1 comment
Labels
enhancement New feature or request go Pull requests that update Go code

Comments

@xorhex
Copy link

xorhex commented Aug 13, 2024

Reviewing the python documentation, one can get the module outputs. How does one access this structure when using golang as Scan returns the matching rules without the module outputs (as far as I can tell)?

// Scan scans the provided data with the Rules associated to the Scanner.
func (s *Scanner) Scan(buf []byte) ([]*Rule, error) {
	var ptr *C.uint8_t
	// When `buf` is an empty slice `ptr` will be nil. That's ok, because
	// yrx_scanner_scan allows the data pointer to be null as long as the data
	// size is 0.
	if len(buf) > 0 {
		ptr = (*C.uint8_t)(unsafe.Pointer(&(buf[0])))
	}

	s.matchingRules = nil

	runtime.LockOSThread()
	defer runtime.UnlockOSThread()

	var err error
	switch r := C.yrx_scanner_scan(s.cScanner, ptr, C.size_t(len(buf))); r {
	case C.SUCCESS:
		err = nil
	case C.SCAN_TIMEOUT:
		err = ErrTimeout
	default:
		err = errors.New(C.GoString(C.yrx_last_error()))
	}

	return s.matchingRules, err
}
@plusvic
Copy link
Member

plusvic commented Aug 13, 2024

Module outputs are are not implemented in the Golang API yet.

@plusvic plusvic added enhancement New feature or request go Pull requests that update Go code labels Aug 13, 2024
@plusvic plusvic changed the title Accessing module_outputs using golang Implement API for accessing module outputs in Go library Aug 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request go Pull requests that update Go code
Projects
None yet
Development

No branches or pull requests

2 participants