Skip to content

✨ Add const block to codegen with LR type names.#5974

Merged
chris-rock merged 3 commits intomainfrom
vasil/lr-codegen-consts
Oct 1, 2025
Merged

✨ Add const block to codegen with LR type names.#5974
chris-rock merged 3 commits intomainfrom
vasil/lr-codegen-consts

Conversation

@VasilSirakov
Copy link
Copy Markdown
Contributor

@VasilSirakov VasilSirakov commented Sep 29, 2025

Enhances LR codegen to also generate a const block with a const corresponding to the name of each type in the LR file. Having a const to reference, e.g. ResourceSomeType instead of manually typing out some.type can be useful in when creating a resource and is less error prone.

Example (core.lr):

package resources

import (
  // ... imports ...
)

// The MQL type names exposed as public consts for ease of reference.
const (
	ResourceMondoo string = "mondoo"
	ResourceAsset string = "asset"
	ResourceAssetEol string = "asset.eol"
	ResourceTime string = "time"
	ResourceRegex string = "regex"
	ResourceParse string = "parse"
	ResourceUuid string = "uuid"
	ResourceCpe string = "cpe"
	ResourceProduct string = "product"
	ResourceProductReleaseCycleInformation string = "product.releaseCycleInformation"
	ResourceVulnerabilityExchange string = "vulnerability.exchange"
)


var resourceFactories map[string]plugin.ResourceFactory
// ... remaining code ...

Going over all existing occurrences and making use of the consts is not high prio and can be done eventually.

@VasilSirakov VasilSirakov marked this pull request as ready for review September 29, 2025 13:25
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Sep 29, 2025

Test Results

4 425 tests  ±0   4 421 ✅ ±0   2m 8s ⏱️ ±0s
  409 suites ±0       4 💤 ±0 
   30 files   ±0       0 ❌ ±0 

Results for commit 99ddaef. ± Comparison against base commit c80d5d3.

♻️ This comment has been updated with latest results.

Signed-off-by: Vasil Sirakov <sirakov97@gmail.com>
Signed-off-by: Vasil Sirakov <sirakov97@gmail.com>
Signed-off-by: Vasil Sirakov <sirakov97@gmail.com>
@VasilSirakov VasilSirakov force-pushed the vasil/lr-codegen-consts branch from f3b1468 to 99ddaef Compare October 1, 2025 06:45
@chris-rock chris-rock merged commit 3f9d3c5 into main Oct 1, 2025
30 of 33 checks passed
@chris-rock chris-rock deleted the vasil/lr-codegen-consts branch October 1, 2025 08:29
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 1, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants