{"id":16842828,"url":"https://github.com/tarunkoyalwar/nestle","last_synced_at":"2025-04-11T05:52:37.969Z","repository":{"id":62711704,"uuid":"557924922","full_name":"tarunKoyalwar/nestle","owner":"tarunKoyalwar","description":"Match and Extract Nested groups (ex: graphql) using regex with Nestle","archived":false,"fork":false,"pushed_at":"2022-11-04T22:14:18.000Z","size":250,"stargazers_count":7,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-11T05:52:32.932Z","etag":null,"topics":["automation","bugbounty","bugbounty-tool","go","graphql","javascript-recon","javascript-regex","recon","regex"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tarunKoyalwar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-10-26T15:02:23.000Z","updated_at":"2025-02-18T13:16:42.000Z","dependencies_parsed_at":"2022-11-04T22:45:41.813Z","dependency_job_id":null,"html_url":"https://github.com/tarunKoyalwar/nestle","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tarunKoyalwar%2Fnestle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tarunKoyalwar%2Fnestle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tarunKoyalwar%2Fnestle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tarunKoyalwar%2Fnestle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tarunKoyalwar","download_url":"https://codeload.github.com/tarunKoyalwar/nestle/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248351408,"owners_count":21089271,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automation","bugbounty","bugbounty-tool","go","graphql","javascript-recon","javascript-regex","recon","regex"],"created_at":"2024-10-13T12:48:39.888Z","updated_at":"2025-04-11T05:52:37.942Z","avatar_url":"https://github.com/tarunKoyalwar.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Nestle\n\n\u003cp align=\"center\" \u003e\n\u003cimg src=\"static/nestle.png\"\u003e\n\u003c/br\u003e\n\u003c/p\u003e\n\n\n\n\nA simple and easy to use wrapper around **regex.Regexp** that allows parsing nested objected like brackets,parenthesis etc . The syntax to validate and match a nested group is `[{:nested:}]` this syntax or match group will validate and match balanced curly brackets.\n\n## Why ??\n\nThere may be lot of cases where this can be used but **nestle** is primarily developed with a use case to extract embedded graphql queries from js files which traditionally is not easy and may not be possible due to nested object fields Ex `me { id address {street location }}`. However this can easily be matched and extracted using nestle .\n\n### How does this work ??\n\nImplementaion of `nestle` is simple it uses 2 regex instances one for regex before say `{` (Prematch group) and another instance for regex after `}` (PostMatch group) .Indexes of these two groups are obtained using `regexp.Regexp.FindAllStringIndex` and continuity and whether the parenthesis are balanced  is validated using a simple expression evaluation algorithm which uses **stack**\n\n### Example/Usecase\nExtract embedded graphql queries from javascript files \n\n~~~\ncat js-file.js | nestle -regex '(query|mutation)\\s+[a-zA-Z]+[0-9]*[a-zA-Z]+(\\([^(\\(|\\))]+\\))*\\s*[{:nested:}]'\n~~~\n\nAbove is 100% working example to extract entire graphql query . A sample graphql text file is located at [graphql.txt](./static/testcase_graphql.txt)\n\n## Disclaimer\n\n1. Nestle Only supports regex that have `:nested:` syntax since it is explicitly designed for this purposes .\n\n2. Nestle currently does not support normal/other/simple regex since there are better options available.\n\n3. Case where regex query only matches parenthesis ex: `[(:nested:)]` is discouraged and blacklisted \n\n\n## Installation \n\n- Install from source\n\n```sh\ngo install -v github.com/tarunKoyalwar/nestle/cmd/nestle@latest\n```\n\n- Install from Releases\n\n\n## Usage \n\nUsing nestle with syntax `[:nested:]` . is simple which can be better understood using below example\n\n**Example**\n\n- Objective :  extract user data ` user {xxx} ` from below graphql query \n\n~~~\nquery me{\n    me {\n        id\n        username\n        user {\n            address {\n                street\n                city\n            }\n            contact {\n                email\n                phone\n            }\n        }\n    }\n}\n~~~\n\nto extract `user {xxx}` including all data between them with parenthesis use regex\n\n~~~\n(user)\\s+[{:nested:}]\n~~~\n\nand that's it . Here nested group is denoted using **[ start_char : nested : end_char ]**\n\n\nOther examples are available in `nestle_test.go` file and a sample file is available at [graphql.txt](./static/testcase_graphql.txt)\n\n\n\nRun below command for help\n\n```sh\nnestle -h\n```\n\n\n# Support\n\nDo start the repo if you liked the project to keeep motivated  and create interesting projects","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftarunkoyalwar%2Fnestle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftarunkoyalwar%2Fnestle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftarunkoyalwar%2Fnestle/lists"}