fix: remove frozen flag definitions and centralise CRE_ALLOW_IMPORT gate#884
Merged
Merged
Conversation
0471fc3 to
63db128
Compare
Collaborator
|
thanks for this pr, due to several last minute debugging changes and a brand new AI taxonomy we had to merge quickly several breaking changes, this is useful can you please resolve the conflicts so we can merge? |
Contributor
Author
|
Yes sure, will do👍 |
63db128 to
ee6c72a
Compare
ENABLE_MYOPENCRE and GAP_ANALYSIS_OPTIMIZED were evaluated once at import/class definition time, freezing their values. Upstream has since removed all usages of both flags, so their frozen definitions in config.py are dropped.
Introduces application/feature_flags.py with is_cre_import_allowed(), which reads os.getenv("CRE_ALLOW_IMPORT") fresh on every call using a TRUE_VALUES whitelist matching upstream gate semantics (1, true, yes).
Also fixes a pre-existing inconsistency in the /rest/v1/config endpoint: it previously returned True only for "1", while the gate accepted "1", "true", and "yes". Both now use is_cre_import_allowed() so the frontend reflects the actual gate state.
Tests updated to remove stale flag patches and use patch.dict for proper env isolation.
ee6c72a to
d5eebbf
Compare
Contributor
Author
|
Hi @northdpole, rebased onto main and resolved the conflicts. The scope shifted during the rebase since upstream had already removed the |
Pa04rth
approved these changes
Apr 26, 2026
Collaborator
|
Merged ! @shiwani42 @PRAteek-singHWY |
Bornunique911
pushed a commit
to Bornunique911/OpenCRE
that referenced
this pull request
Apr 26, 2026
…ate (OWASP#884) ENABLE_MYOPENCRE and GAP_ANALYSIS_OPTIMIZED were evaluated once at import/class definition time, freezing their values. Upstream has since removed all usages of both flags, so their frozen definitions in config.py are dropped. Introduces application/feature_flags.py with is_cre_import_allowed(), which reads os.getenv("CRE_ALLOW_IMPORT") fresh on every call using a TRUE_VALUES whitelist matching upstream gate semantics (1, true, yes). Also fixes a pre-existing inconsistency in the /rest/v1/config endpoint: it previously returned True only for "1", while the gate accepted "1", "true", and "yes". Both now use is_cre_import_allowed() so the frontend reflects the actual gate state. Tests updated to remove stale flag patches and use patch.dict for proper env isolation.
Bornunique911
pushed a commit
to Bornunique911/OpenCRE
that referenced
this pull request
Apr 26, 2026
…ate (OWASP#884) ENABLE_MYOPENCRE and GAP_ANALYSIS_OPTIMIZED were evaluated once at import/class definition time, freezing their values. Upstream has since removed all usages of both flags, so their frozen definitions in config.py are dropped. Introduces application/feature_flags.py with is_cre_import_allowed(), which reads os.getenv("CRE_ALLOW_IMPORT") fresh on every call using a TRUE_VALUES whitelist matching upstream gate semantics (1, true, yes). Also fixes a pre-existing inconsistency in the /rest/v1/config endpoint: it previously returned True only for "1", while the gate accepted "1", "true", and "yes". Both now use is_cre_import_allowed() so the frontend reflects the actual gate state. Tests updated to remove stale flag patches and use patch.dict for proper env isolation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #871
Closes #869
Summary
Removed frozen
ENABLE_MYOPENCREandGAP_ANALYSIS_OPTIMIZEDdefinitions fromconfig.py. Upstream has since removed all usages of both flags; the frozen definitions were dead code.Introduces
application/feature_flags.pywithis_cre_import_allowed(), which readsos.getenv("CRE_ALLOW_IMPORT")fresh on every call using aTRUE_VALUESwhitelist (1,true,yes) matching upstream gate semantics.Also fixes a pre-existing inconsistency in the
/rest/v1/configendpoint: it previously returnedTrueonly for"1", while the gate accepted"1","true", and"yes". Both now useis_cre_import_allowed()so the frontend reflects the actual gate state.Why
Upstream removed the usages of
ENABLE_MYOPENCREandGAP_ANALYSIS_OPTIMIZEDfromweb_main.pyanddb.py, but left their frozen definitions inconfig.pyas dead code. This PR cleans them up.CRE_ALLOW_IMPORThad the same import-time risk and was duplicated inline across multiple call sites inweb_main.pywith slightly inconsistent semantics (the gate and the/rest/v1/configendpoint checked different value sets). Centralising intofeature_flags.pygives it a single source of truth and prevents future drift.Changes
application/feature_flags.py(new) -is_cre_import_allowed()reads dynamically at call timeapplication/config.py- removed dead frozen definitions ofENABLE_MYOPENCREandGAP_ANALYSIS_OPTIMIZEDapplication/web/web_main.py- useis_cre_import_allowed()at allCRE_ALLOW_IMPORTcall sites;/rest/v1/confignow reflects the actual gate stateapplication/tests/gap_analysis_db_test.py- removed staleConfig.GAP_ANALYSIS_OPTIMIZEDpatch; tiered pruning is always-onapplication/tests/web_main_test.py- usepatch.dict(os.environ, ...)for proper env isolationTest plan
test_tiered_execution_optimizationpassestest_get_cre_csvpassestest_import_from_cre_csvpassestest_parse_row_dicts_produces_cres_and_new_standardsskips when fixture fileOpenCRE-AI-6-WithMitre.csvis absent, pre-existing and unrelated to this change)blackformatting verified