@oracle/oraclejet-audit 10.0.0 → 11.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/jaf-amd.js +12 -4
- package/jaf.js +6 -1
- package/jafapi.js +6 -1
- package/lib/AST.js +6 -1
- package/lib/AST_Ts.js +6 -1
- package/lib/AstJson.js +6 -1
- package/lib/AstNodeTypes.js +6 -1
- package/lib/Comments.js +6 -1
- package/lib/ComponentSvcs.js +5 -0
- package/lib/Components.js +6 -1
- package/lib/Config.js +6 -1
- package/lib/ConfigLib.js +6 -1
- package/lib/CssLib.js +5 -0
- package/lib/CssUtils.js +5 -0
- package/lib/DomUtils.js +6 -1
- package/lib/FileIndex.js +5 -0
- package/lib/FileSet.js +5 -0
- package/lib/FsUtils.js +6 -1
- package/lib/Histo.js +6 -0
- package/lib/HtmlTree.js +6 -1
- package/lib/HtmlUtils.js +5 -0
- package/lib/Issue.js +5 -0
- package/lib/JafEvents.js +5 -0
- package/lib/JafLib.js +6 -1
- package/lib/Json.js +6 -0
- package/lib/JsonLoader.js +6 -1
- package/lib/MetaLib.js +6 -1
- package/lib/NetUtils.js +5 -0
- package/lib/NodeTypes.js +5 -0
- package/lib/Parser.js +6 -1
- package/lib/RegTypes.js +5 -0
- package/lib/Registry.js +5 -0
- package/lib/Reporter.js +5 -0
- package/lib/RuleContext.js +5 -0
- package/lib/RulePack.js +5 -0
- package/lib/RuleSet.js +6 -1
- package/lib/Rules.js +6 -1
- package/lib/Scope.js +6 -1
- package/lib/SemVer.js +5 -0
- package/lib/Server.js +5 -0
- package/lib/SevLib.js +5 -0
- package/lib/Severity.js +6 -1
- package/lib/Stats.js +6 -0
- package/lib/Ts.js +6 -1
- package/lib/Utils.js +6 -1
- package/lib/Watch.js +5 -0
- package/lib/Writer.js +5 -0
- package/lib/ZipUtils.js +5 -0
- package/lib/api.js +6 -0
- package/lib/cliStats.js +6 -0
- package/lib/clone.js +5 -0
- package/lib/cmdline.js +6 -1
- package/lib/colors.js +5 -0
- package/lib/exportRules.js +6 -0
- package/lib/extends.js +6 -0
- package/lib/filetypes.js +6 -0
- package/lib/groups.js +6 -0
- package/lib/help.js +6 -1
- package/lib/imanual.js +6 -0
- package/lib/jetver.js +6 -1
- package/lib/macros.js +6 -0
- package/lib/metaLoader.js +5 -0
- package/lib/metahist.js +5 -0
- package/lib/msgidLoader.js +6 -1
- package/lib/ns.js +6 -1
- package/lib/nslist.js +6 -1
- package/lib/outFormat.js +6 -0
- package/lib/outfile.js +5 -0
- package/lib/ruleLoader.js +5 -0
- package/lib/scaffold.js +6 -1
- package/lib/scaffoldRule.js +6 -1
- package/lib/schema.js +5 -0
- package/lib/scopewalker.js +6 -0
- package/lib/spinner.js +5 -0
- package/lib/spinnernoop.js +5 -0
- package/lib/tabs.js +5 -0
- package/lib/xmanual.js +6 -0
- package/libext/expparser.js +6 -1
- package/meta/10.1.0/jetauditmeta.js +9 -0
- package/meta/11.0.0/jetauditmeta.js +9 -0
- package/meta/11.1.0/jetauditmeta.js +9 -0
- package/meta/metaverlist.json +1 -1
- package/package.json +2 -3
- package/rulepacks/csp/csp-html-script-unsafe-inline.js +5 -0
- package/rulepacks/csp/csp-html-style-unsafe-inline.js +5 -0
- package/rulepacks/csp/csp-html-unsafe-expr.js +5 -0
- package/rulepacks/csp/csp-js-script-unsafe-eval.js +6 -1
- package/rulepacks/csp/csp-js-style-unsafe-inline.js +5 -0
- package/rulepacks/csp/csp-ts-script-unsafe-eval.js +6 -0
- package/rulepacks/csp/csp-ts-style-unsafe-inline.js +6 -0
- package/rulepacks/csp/msgid.json +6 -1
- package/rulepacks/csp/rules.json +6 -1
- package/rulepacks/jetwc/jetwc-absolute-jetversion.js +6 -1
- package/rulepacks/jetwc/jetwc-aria-redefinition.js +6 -1
- package/rulepacks/jetwc/jetwc-bootstrap.js +6 -1
- package/rulepacks/jetwc/jetwc-compjson-bp-ar.js +6 -1
- package/rulepacks/jetwc/jetwc-compjson-bp-obj.js +6 -1
- package/rulepacks/jetwc/jetwc-component-dependencies.js +6 -1
- package/rulepacks/jetwc/jetwc-component-displayname.js +6 -1
- package/rulepacks/jetwc/jetwc-component-foldername.js +6 -1
- package/rulepacks/jetwc/jetwc-component-location.js +6 -1
- package/rulepacks/jetwc/jetwc-component-type.js +6 -1
- package/rulepacks/jetwc/jetwc-data-property-prefix.js +6 -1
- package/rulepacks/jetwc/jetwc-deprecated-lifecycle.js +6 -1
- package/rulepacks/jetwc/jetwc-disabled-property.js +6 -1
- package/rulepacks/jetwc/jetwc-displayname.js +6 -1
- package/rulepacks/jetwc/jetwc-dynamic-slot-context.js +6 -1
- package/rulepacks/jetwc/jetwc-dynamic-slots-naming.js +6 -1
- package/rulepacks/jetwc/jetwc-event-displayname.js +6 -1
- package/rulepacks/jetwc/jetwc-events.js +6 -1
- package/rulepacks/jetwc/jetwc-jet-version.js +6 -1
- package/rulepacks/jetwc/jetwc-loader-file.js +6 -1
- package/rulepacks/jetwc/jetwc-method-displayname.js +6 -1
- package/rulepacks/jetwc/jetwc-methods.js +6 -1
- package/rulepacks/jetwc/jetwc-namespace.js +6 -1
- package/rulepacks/jetwc/jetwc-nested-defaults.js +6 -1
- package/rulepacks/jetwc/jetwc-nls-languages.js +6 -1
- package/rulepacks/jetwc/jetwc-nls-root.js +6 -1
- package/rulepacks/jetwc/jetwc-oj-register.js +6 -1
- package/rulepacks/jetwc/jetwc-ojcss.js +6 -1
- package/rulepacks/jetwc/jetwc-pack-children.js +6 -1
- package/rulepacks/jetwc/jetwc-packable-components.js +6 -1
- package/rulepacks/jetwc/jetwc-prerelease-dependencies.js +6 -1
- package/rulepacks/jetwc/jetwc-prerelease-pattern.js +6 -1
- package/rulepacks/jetwc/jetwc-prerelease-version.js +6 -1
- package/rulepacks/jetwc/jetwc-property-changed.js +6 -1
- package/rulepacks/jetwc/jetwc-property-displayname.js +6 -1
- package/rulepacks/jetwc/jetwc-property-nesting.js +6 -1
- package/rulepacks/jetwc/jetwc-public-modules.js +6 -1
- package/rulepacks/jetwc/jetwc-register-css.js +6 -1
- package/rulepacks/jetwc/jetwc-register-with-promises.js +6 -1
- package/rulepacks/jetwc/jetwc-require-paths.js +6 -1
- package/rulepacks/jetwc/jetwc-required-subproperty.js +6 -0
- package/rulepacks/jetwc/jetwc-reserved-property.js +6 -1
- package/rulepacks/jetwc/jetwc-schema.js +6 -1
- package/rulepacks/jetwc/jetwc-semantic-version.js +6 -1
- package/rulepacks/jetwc/jetwc-slot-displayname.js +6 -1
- package/rulepacks/jetwc/jetwc-slots.js +6 -1
- package/rulepacks/jetwc/jetwc-standard-files.js +6 -1
- package/rulepacks/jetwc/jetwc-subproperty-writeback.js +6 -0
- package/rulepacks/jetwc/jetwc-template-slots.js +6 -1
- package/rulepacks/jetwc/jetwc-unused-events.js +6 -1
- package/rulepacks/jetwc/jetwc-unused-slots.js +6 -1
- package/rulepacks/jetwc/jetwc-vb-category.js +6 -1
- package/rulepacks/jetwc/jetwc-vb-icon.js +6 -1
- package/rulepacks/jetwc/jetwc-version-openrange.js +6 -1
- package/rulepacks/jetwc/jetwc-writeback-required.js +6 -1
- package/rulepacks/jetwc/msgid.json +6 -0
- package/rulepacks/jetwc/rules.json +6 -1
- package/rulepacks/jetwc-lib/component-audit-utils.js +6 -1
- package/rulepacks/jetwco/jetwco-bootstrap.js +6 -1
- package/rulepacks/jetwco/jetwco-compjson-ns-reg.js +6 -1
- package/rulepacks/jetwco/jetwco-component-api-baseline-changes.js +6 -0
- package/rulepacks/jetwco/jetwco-component-api-changes.js +6 -1
- package/rulepacks/jetwco/jetwco-component-cdn.js +6 -1
- package/rulepacks/jetwco/jetwco-exchange-version-check.js +6 -1
- package/rulepacks/jetwco/jetwco-license-info.js +6 -1
- package/rulepacks/jetwco/jetwco-prerelease-cdn.js +6 -1
- package/rulepacks/jetwco/jetwco-thirdparty-ba.js +6 -1
- package/rulepacks/jetwco/msgid.json +6 -0
- package/rulepacks/jetwco/rules.json +6 -1
- package/rulepacks/spoc/msgid.json +5 -0
- package/rulepacks/spoc/rules.json +5 -0
- package/rulepacks/spoc/spoc-dom-manip-inv-tag.js +5 -0
- package/rulepacks/spoc/spoc-dom-manip-tag-pos.js +5 -0
- package/rulepacks/spoc/spoc-dom-manip.js +5 -0
- package/rules/jaf/jaf-css-diagnose.js +5 -0
- package/rules/jaf/jaf-html-diagnose.js +5 -0
- package/rules/jaf/jaf-init-schema.js +5 -0
- package/rules/jaf/jaf-js-diagnose.js +5 -0
- package/rules/jaf/jaf-ts-diagnose.js +6 -0
- package/rules/jaf/msgid.json +6 -1
- package/rules/jaf/rules.json +6 -1
- package/rules/jet/helpers/acc-aria-label.js +6 -1
- package/rules/jet/helpers/bp-checkPropType.js +5 -0
- package/rules/jet/helpers/cssHelper.js +6 -1
- package/rules/jet/helpers/extractStylesFromClass.js +6 -1
- package/rules/jet/helpers/has-slot-name.js +6 -1
- package/rules/jet/helpers/has-slot.js +5 -0
- package/rules/jet/helpers/json-prop-pos.js +5 -0
- package/rules/jet/helpers/json-propname-pos.js +5 -0
- package/rules/jet/helpers/style-selector.js +6 -1
- package/rules/jet/helpers/valid-attr.js +5 -0
- package/rules/jet/helpers/vartrack.js +5 -0
- package/rules/jet/jet-css-ojselector.js +5 -0
- package/rules/jet/msgid.json +6 -1
- package/rules/jet/oj-acc-aria-labelledby.js +5 -0
- package/rules/jet/oj-acc-aria-prop.js +5 -0
- package/rules/jet/oj-acc-avatar-aria-role.js +5 -0
- package/rules/jet/oj-acc-combobox-aria-label.js +6 -1
- package/rules/jet/oj-acc-film-strip-aria-label.js +5 -0
- package/rules/jet/oj-acc-input-aria-label.js +6 -1
- package/rules/jet/oj-acc-select-aria-label.js +6 -1
- package/rules/jet/oj-cca-compjson-bp-ar.js +5 -0
- package/rules/jet/oj-cca-compjson-bp-dsplyname.js +5 -0
- package/rules/jet/oj-cca-compjson-bp-jetver.js +5 -0
- package/rules/jet/oj-cca-compjson-bp-obj.js +5 -0
- package/rules/jet/oj-cca-compjson-ns-reg.js +5 -0
- package/rules/jet/oj-css-bp-border-color.js +5 -0
- package/rules/jet/oj-css-bp-dir-flow.js +6 -1
- package/rules/jet/oj-css-bp-float.js +5 -0
- package/rules/jet/oj-css-bp-textalign.js +5 -0
- package/rules/jet/oj-css-style-abs-units.js +5 -0
- package/rules/jet/oj-css-style-bp-color.js +6 -1
- package/rules/jet/oj-css-style-bp-display.js +6 -1
- package/rules/jet/oj-css-style-bp-font-family.js +6 -1
- package/rules/jet/oj-css-style-bp-font.js +5 -0
- package/rules/jet/oj-css-style-deprecated.js +6 -1
- package/rules/jet/oj-css-style-override.js +6 -1
- package/rules/jet/oj-css-var-override.js +5 -0
- package/rules/jet/oj-form-maxcols.js +6 -0
- package/rules/jet/oj-html-5-attr-obs.js +5 -0
- package/rules/jet/oj-html-5-tag-obs.js +5 -0
- package/rules/jet/oj-html-attr-$unique.js +5 -0
- package/rules/jet/oj-html-attr-2def.js +5 -0
- package/rules/jet/oj-html-attr-json.js +6 -1
- package/rules/jet/oj-html-attr-prefix-expr.js +6 -1
- package/rules/jet/oj-html-attr-prefix-ro.js +5 -0
- package/rules/jet/oj-html-attr-req.js +5 -0
- package/rules/jet/oj-html-bindforeach-data.js +5 -0
- package/rules/jet/oj-html-bindif-test.js +5 -0
- package/rules/jet/oj-html-binding-attr.js +5 -0
- package/rules/jet/oj-html-cca-count.js +5 -0
- package/rules/jet/oj-html-cca-tagname.js +6 -1
- package/rules/jet/oj-html-cdn.js +5 -0
- package/rules/jet/oj-html-combo-converter.js +5 -0
- package/rules/jet/oj-html-cspexpr.js +6 -1
- package/rules/jet/oj-html-databind-all.js +5 -0
- package/rules/jet/oj-html-dlg-title.js +5 -0
- package/rules/jet/oj-html-file-pick-accept.js +6 -0
- package/rules/jet/oj-html-form-bindif.js +6 -1
- package/rules/jet/oj-html-form-layout-maxcols.js +6 -0
- package/rules/jet/oj-html-form-noflex.js +5 -0
- package/rules/jet/oj-html-input-isodate.js +6 -0
- package/rules/jet/oj-html-invalid-doctype.js +6 -1
- package/rules/jet/oj-html-jq-databind.js +6 -1
- package/rules/jet/oj-html-ko-comment.js +5 -0
- package/rules/jet/oj-html-ko-databind.js +5 -0
- package/rules/jet/oj-html-label-for-prefix.js +5 -0
- package/rules/jet/oj-html-missing-doctype.js +6 -1
- package/rules/jet/oj-html-oj-lib.js +5 -0
- package/rules/jet/oj-html-ojattr-520.js +6 -1
- package/rules/jet/oj-html-ojattr-deprecated.js +6 -1
- package/rules/jet/oj-html-ojattr-enum-deprecated.js +6 -1
- package/rules/jet/oj-html-ojattr-evt-syntax.js +5 -0
- package/rules/jet/oj-html-ojattr-value.js +6 -1
- package/rules/jet/oj-html-ojattr.js +6 -1
- package/rules/jet/oj-html-ojevent.js +6 -1
- package/rules/jet/oj-html-ojslot.js +5 -0
- package/rules/jet/oj-html-ojstyle.js +5 -0
- package/rules/jet/oj-html-ojtag-datacmd.js +6 -1
- package/rules/jet/oj-html-ojtag-datactx.js +5 -0
- package/rules/jet/oj-html-ojtag-deprecated.js +6 -1
- package/rules/jet/oj-html-ojtag-globattr-noprefix.js +5 -0
- package/rules/jet/oj-html-ojtag-id.js +5 -0
- package/rules/jet/oj-html-ojtag-nonglobattr-prefix.js +5 -0
- package/rules/jet/oj-html-ojtag-ns.js +5 -0
- package/rules/jet/oj-html-picker-attrs.js +6 -0
- package/rules/jet/oj-html-redwood-cssnovars.js +6 -0
- package/rules/jet/oj-html-redwood-cssvars.js +6 -0
- package/rules/jet/oj-html-self-close.js +5 -0
- package/rules/jet/oj-html-slot-item-minmax.js +6 -0
- package/rules/jet/oj-html-slot-name.js +6 -1
- package/rules/jet/oj-html-slot-pref-content.js +6 -0
- package/rules/jet/oj-html-style-abs-units.js +5 -0
- package/rules/jet/oj-html-style-bp-color.js +5 -0
- package/rules/jet/oj-html-style-bp-display.js +6 -1
- package/rules/jet/oj-html-style-bp-font-family.js +5 -0
- package/rules/jet/oj-html-style-bp-font.js +5 -0
- package/rules/jet/oj-html-style-deprecated.js +5 -0
- package/rules/jet/oj-html-style.js +6 -1
- package/rules/jet/oj-html-stylesel.js +6 -1
- package/rules/jet/oj-html-tag-attr-noprefix.js +5 -0
- package/rules/jet/oj-html-template-index.js +6 -0
- package/rules/jet/oj-html-unsup-theme.js +6 -1
- package/rules/jet/oj-html-wctag-$props.js +6 -1
- package/rules/jet/oj-html-wctag-arialabelledby.js +5 -0
- package/rules/jet/oj-html-wctag-for.js +5 -0
- package/rules/jet/oj-html-wctag-id.js +5 -0
- package/rules/jet/oj-html-wctag-packprivate.js +6 -0
- package/rules/jet/oj-js-comp-attr-deprecated.js +5 -0
- package/rules/jet/oj-js-comp-meth-deprecated.js +5 -0
- package/rules/jet/oj-js-no-ext-final.js +5 -0
- package/rules/jet/oj-js-noconsole.js +5 -0
- package/rules/jet/oj-js-ojcomp-deprecated.js +6 -1
- package/rules/jet/oj-js-ojcomp-exist.js +5 -0
- package/rules/jet/oj-js-ojcomp-new.js +5 -0
- package/rules/jet/oj-js-poly-promise.js +6 -1
- package/rules/jet/oj-js-var-undef.js +5 -0
- package/rules/jet/oj-json-syntax.js +6 -1
- package/rules/jet/oj-ts-comp-attr-deprecated.js +5 -0
- package/rules/jet/oj-ts-comp-meth-deprecated.js +5 -0
- package/rules/jet/oj-ts-no-ext-final.js +6 -0
- package/rules/jet/oj-ts-noconsole.js +6 -1
- package/rules/jet/oj-ts-ojcomp-deprecated.js +6 -1
- package/rules/jet/oj-ts-ojcomp-exist.js +6 -1
- package/rules/jet/oj-ts-ojcomp-new.js +6 -1
- package/rules/jet/oj-ts-poly-promise.js +6 -1
- package/rules/jet/rules.json +6 -1
- package/schema/component-schema.json +122 -2
- package/src/JafCore.js +6 -1
- package/types/index.d.ts +144 -35
- package/lib/manual.js +0 -1
- package/lib/stats.js +0 -1
- package/rules/exch/helpers/json-prop-pos.js +0 -1
- package/rules/exch/msgid.json +0 -1
- package/rules/exch/oj-cca-comp-zip-content-composite.js +0 -1
- package/rules/exch/oj-cca-comp-zip-content-pack.js +0 -1
- package/rules/exch/oj-cca-comp-zip-expand.js +0 -1
- package/rules/exch/oj-cca-compjson-evnames.js +0 -1
- package/rules/exch/oj-cca-compjson-file.js +0 -1
- package/rules/exch/oj-cca-compjson-prefix.js +0 -1
- package/rules/exch/oj-cca-compjson-prop-compdeps.js +0 -1
- package/rules/exch/oj-cca-compjson-prop-deps.js +0 -1
- package/rules/exch/oj-cca-compjson-prop-jetver.js +0 -1
- package/rules/exch/oj-cca-compjson-prop-obs.js +0 -1
- package/rules/exch/oj-cca-compjson-prop-type.js +0 -1
- package/rules/exch/oj-cca-compjson-prop-types.js +0 -1
- package/rules/exch/oj-cca-compjson-prop-undef.js +0 -1
- package/rules/exch/oj-cca-compjson-prop-version.js +0 -1
- package/rules/exch/oj-cca-compjson-schema.js +0 -1
- package/rules/exch/oj-cca-zip-compjson.js +0 -1
- package/rules/exch/rules.json +0 -1
- package/rules/jet/oj-css-bp-bgcolor.js +0 -1
- package/tests/components/attr-req-test/component.json +0 -1
- package/tests/components/demo-analog-clock/component.json +0 -1
- package/tests/components/demo-analog-clock/demo-analog-clock-viewModel.js +0 -1
- package/tests/components/demo-analog-clock/extension/demo/js/viewModels/demo.js +0 -1
- package/tests/components/demo-analog-clock/loader.js +0 -1
- package/tests/components/demo-card/component.json +0 -1
- package/tests/components/demo-chart-orientation-control/component.json +0 -1
- package/tests/components/demo-chart-stack-control/component.json +0 -1
- package/tests/components/made-up/component.json +0 -1
- package/tests/components/oj-made-up/component.json +0 -1
- package/tests/components/sp-activity-item/component.json +0 -1
- package/tests/config/config_base.json +0 -1
- package/tests/golden/10.0.0/golden_base.json +0 -1
- package/tests/golden/8.1.0/golden_base.json +0 -1
- package/tests/golden/9.0.0/golden_base.json +0 -1
- package/tests/rulepacks/hooks/hook-rpext.js +0 -1
- package/tests/rulepacks/hooks/hook-start-close-rulepack.js +0 -1
- package/tests/rulepacks/hooks/rule-rpext.js +0 -1
- package/tests/rulepacks/hooks/rules.json +0 -1
- package/tests/rulepacks/tags/proc_directive.js +0 -1
- package/tests/rulepacks/tags/rules.json +0 -1
- package/tests/rulepacks/tags/tag-count-setup.js +0 -1
- package/tests/rulepacks/tags/tag-count.js +0 -1
- package/tests/rules/bugs/JET-4770_PASS_1.html +0 -9
- package/tests/rules/comments/com_FAIL_1.js +0 -57
- package/tests/rules/comments/com_FAIL_2.js +0 -96
- package/tests/rules/comments/com_PASS_1.js +0 -42
- package/tests/rules/comments/com_PASS_2.js +0 -63
- package/tests/rules/comments/com_PASS_3.js +0 -40
- package/tests/rules/comments/com_PASS_4.js +0 -36
- package/tests/rules/comments/com_PASS_5.js +0 -19
- package/tests/rules/csp/html-script-unsafe-inline/FAIL_1.html +0 -11
- package/tests/rules/csp/html-script-unsafe-inline/FAIL_2.html +0 -8
- package/tests/rules/csp/html-script-unsafe-inline/PASS_1.html +0 -8
- package/tests/rules/csp/html-script-unsafe-inline/PASS_2.html +0 -8
- package/tests/rules/csp/html-script-unsafe-inline/PASS_3.html +0 -8
- package/tests/rules/csp/html-style-unsafe-inline/FAIL_1.html +0 -11
- package/tests/rules/csp/html-style-unsafe-inline/PASS_1.html +0 -11
- package/tests/rules/csp/html-unsafe-expr/FAIL_1.html +0 -14
- package/tests/rules/csp/html-unsafe-expr/PASS_1.html +0 -23
- package/tests/rules/csp/js-script-unsafe-eval/FAIL_1.js +0 -17
- package/tests/rules/csp/js-script-unsafe-eval/FAIL_2.js +0 -40
- package/tests/rules/csp/js-script-unsafe-eval/FAIL_3.js +0 -22
- package/tests/rules/csp/js-script-unsafe-eval/PASS_1.js +0 -20
- package/tests/rules/csp/js-script-unsafe-eval/PASS_2.js +0 -44
- package/tests/rules/csp/js-script-unsafe-eval/PASS_3.js +0 -16
- package/tests/rules/csp/js-style-unsafe-inline/FAIL_1.js +0 -25
- package/tests/rules/csp/js-style-unsafe-inline/PASS.js +0 -22
- package/tests/rules/demo/noself_FAIL_1.js +0 -101
- package/tests/rules/import/import_FAIL_1.js +0 -11
- package/tests/rules/import/import_PASS_1.js +0 -10
- package/tests/rules/jet-composites/demo-buttonset-enum/component.json +0 -57
- package/tests/rules/jet-composites/demo-buttonset-enum/loader.js +0 -19
- package/tests/rules/jet-composites/demo-buttonset-enum/view.html +0 -48
- package/tests/rules/jet-composites/demo-card/component.json +0 -28
- package/tests/rules/jet-composites/demo-card/loader.js +0 -16
- package/tests/rules/jet-composites/demo-card/view.html +0 -30
- package/tests/rules/jet-composites/demo-card/viewModel.js +0 -46
- package/tests/rules/jet-composites/demo-card/view_PASS_1.html +0 -21
- package/tests/rules/jet-composites/demo-contact-form/component.json +0 -23
- package/tests/rules/jet-composites/demo-contact-form/loader.js +0 -16
- package/tests/rules/jet-composites/demo-contact-form/view.html +0 -9
- package/tests/rules/jet-composites/demo-grocery-list/component.json +0 -18
- package/tests/rules/jet-composites/demo-grocery-list/loader.js +0 -19
- package/tests/rules/jet-composites/demo-grocery-list/view.html +0 -22
- package/tests/rules/jet-composites/demo-grocery-list/viewModel.js +0 -48
- package/tests/rules/jet-composites/dummy-component-1/component.json +0 -82
- package/tests/rules/jet-composites/dummy-component-2/component.json +0 -72
- package/tests/rules/jet-composites/foo-my-cca/component.json +0 -14
- package/tests/rules/jet-composites/foo-unsup-theme/component.json +0 -29
- package/tests/rules/jet-composites/header/component.json +0 -12
- package/tests/rules/jet-composites/oj-cgbu-omc/attribute-selection/component.json +0 -154
- package/tests/rules/jet-composites/oj-cgbu-omc/component.json +0 -11
- package/tests/rules/jet-composites/oj-cgbu-omc/reference/component.json +0 -185
- package/tests/rules/jet-composites/oj-cgbu-omc/wctag_props_FAIL_1.html +0 -34
- package/tests/rules/jet-composites/oj-enum-depr/component.json +0 -69
- package/tests/rules/jet-composites/oj-html-wctag-id/id_FAIL_1.html +0 -10
- package/tests/rules/jet-composites/oj-html-wctag-id/id_PASS_1.html +0 -6
- package/tests/rules/misc/oj.js +0 -12
- package/tests/rules/oj-acc-aria-labelledby/aria_labelledby_FAIL_1.html +0 -23
- package/tests/rules/oj-acc-aria-labelledby/aria_labelledby_FAIL_2.html +0 -22
- package/tests/rules/oj-acc-aria-labelledby/aria_labelledby_PASS_1.html +0 -23
- package/tests/rules/oj-acc-aria-labelledby/aria_labelledby_PASS_2.html +0 -22
- package/tests/rules/oj-acc-aria-labelledby/aria_labelledby_PASS_3.html +0 -22
- package/tests/rules/oj-acc-aria-labelledby/aria_labelledby_PASS_4.html +0 -22
- package/tests/rules/oj-acc-aria-labelledby/aria_labelledby_PASS_5.html +0 -22
- package/tests/rules/oj-acc-aria-prop/aria_prop_FAIL_1.html +0 -22
- package/tests/rules/oj-acc-avatar-aria-role/aria_avatar_role_FAIL_1.html +0 -20
- package/tests/rules/oj-acc-avatar-aria-role/aria_avatar_role_PASS_1.html +0 -23
- package/tests/rules/oj-acc-avatar-aria-role/aria_avatar_role_PASS_2.html +0 -24
- package/tests/rules/oj-acc-avatar-aria-role/aria_avatar_role_PASS_3.html +0 -21
- package/tests/rules/oj-acc-avatar-aria-role/aria_avatar_role_PASS_4.html +0 -22
- package/tests/rules/oj-acc-avatar-aria-role/aria_avatar_role_PASS_5.html +0 -22
- package/tests/rules/oj-acc-combobox-aria-label/aria_combo_many_FAIL_1.html +0 -20
- package/tests/rules/oj-acc-combobox-aria-label/aria_combo_many_FAIL_2.html +0 -21
- package/tests/rules/oj-acc-combobox-aria-label/aria_combo_many_PASS_1.html +0 -20
- package/tests/rules/oj-acc-combobox-aria-label/aria_combo_one_FAIL_1.html +0 -21
- package/tests/rules/oj-acc-combobox-aria-label/aria_combo_one_FAIL_2.html +0 -22
- package/tests/rules/oj-acc-combobox-aria-label/aria_combo_one_PASS_1.html +0 -22
- package/tests/rules/oj-acc-film-strip-aria-label/aria_filmstrip_FAIL_1.html +0 -18
- package/tests/rules/oj-acc-film-strip-aria-label/aria_filmstrip_FAIL_2.html +0 -18
- package/tests/rules/oj-acc-film-strip-aria-label/aria_filmstrip_PASS_1.html +0 -18
- package/tests/rules/oj-acc-film-strip-aria-label/aria_filmstrip_PASS_2.html +0 -19
- package/tests/rules/oj-acc-film-strip-aria-label/aria_filmstrip_PASS_3.html +0 -22
- package/tests/rules/oj-acc-input-aria-label/oj_input_date_FAIL_1.html +0 -21
- package/tests/rules/oj-acc-input-aria-label/oj_input_date_FAIL_2.html +0 -22
- package/tests/rules/oj-acc-input-aria-label/oj_input_date_PASS_1.html +0 -16
- package/tests/rules/oj-acc-input-aria-label/oj_input_date_PASS_2.html +0 -17
- package/tests/rules/oj-acc-input-aria-label/oj_input_date_PASS_3.html +0 -26
- package/tests/rules/oj-acc-input-aria-label/oj_input_date_time_FAIL_1.html +0 -19
- package/tests/rules/oj-acc-input-aria-label/oj_input_date_time_FAIL_2.html +0 -20
- package/tests/rules/oj-acc-input-aria-label/oj_input_date_time_PASS_1.html +0 -19
- package/tests/rules/oj-acc-input-aria-label/oj_input_number_FAIL_1.html +0 -17
- package/tests/rules/oj-acc-input-aria-label/oj_input_number_FAIL_2.html +0 -18
- package/tests/rules/oj-acc-input-aria-label/oj_input_number_PASS_1.html +0 -17
- package/tests/rules/oj-acc-input-aria-label/oj_input_password_FAIL_1.html +0 -17
- package/tests/rules/oj-acc-input-aria-label/oj_input_password_FAIL_2.html +0 -17
- package/tests/rules/oj-acc-input-aria-label/oj_input_password_PASS_1.html +0 -17
- package/tests/rules/oj-acc-input-aria-label/oj_input_text_3_PASS_1.html +0 -20
- package/tests/rules/oj-acc-input-aria-label/oj_input_text_FAIL_1.html +0 -20
- package/tests/rules/oj-acc-input-aria-label/oj_input_text_FAIL_2.html +0 -21
- package/tests/rules/oj-acc-input-aria-label/oj_input_text_PASS_2.html +0 -62
- package/tests/rules/oj-acc-input-aria-label/oj_input_text_nolabel_PASS_2.html +0 -17
- package/tests/rules/oj-acc-input-aria-label/oj_input_time_FAIL_1.html +0 -19
- package/tests/rules/oj-acc-input-aria-label/oj_input_time_FAIL_2.html +0 -20
- package/tests/rules/oj-acc-input-aria-label/oj_input_time_PASS_1.html +0 -19
- package/tests/rules/oj-acc-select-aria-label/aria_selectmany_FAIL_1.html +0 -19
- package/tests/rules/oj-acc-select-aria-label/aria_selectmany_FAIL_2.html +0 -20
- package/tests/rules/oj-acc-select-aria-label/aria_selectmany_PASS_1.html +0 -19
- package/tests/rules/oj-acc-select-aria-label/aria_selectone_FAIL_1.html +0 -20
- package/tests/rules/oj-acc-select-aria-label/aria_selectone_FAIL_2.html +0 -21
- package/tests/rules/oj-cca-comp-zip/zip_FAIL_1.zip +0 -1
- package/tests/rules/oj-cca-comp-zip/zip_FAIL_2.zip +0 -0
- package/tests/rules/oj-cca-comp-zip/zip_FAIL_3.zip +0 -0
- package/tests/rules/oj-cca-comp-zip/zip_FAIL_4.zip +0 -0
- package/tests/rules/oj-cca-comp-zip/zip_FAIL_5.zip +0 -0
- package/tests/rules/oj-cca-comp-zip/zip_FAIL_6.zip +0 -0
- package/tests/rules/oj-cca-comp-zip/zip_FAIL_7.zip +0 -0
- package/tests/rules/oj-cca-comp-zip/zip_FAIL_8.zip +0 -0
- package/tests/rules/oj-cca-comp-zip/zip_PASS_1.zip +0 -0
- package/tests/rules/oj-cca-ns-reg/oj-cca-ns-FAIL_1/component.json +0 -19
- package/tests/rules/oj-cca-ns-reg/oj-cca-ns-PASS_1/component.json +0 -19
- package/tests/rules/oj-cgbu-omc_tests/html_ojevent_FAIL_1.html +0 -15
- package/tests/rules/oj-cgbu-omc_tests/html_ojevent_PASS_1.html +0 -17
- package/tests/rules/oj-compjson-syntax/ojcomp-FAIL_1/component.json +0 -16
- package/tests/rules/oj-compjson-syntax/ojcomp-FAIL_10/component.json +0 -103
- package/tests/rules/oj-compjson-syntax/ojcomp-FAIL_11/component.json +0 -24
- package/tests/rules/oj-compjson-syntax/ojcomp-FAIL_12/component.json +0 -17
- package/tests/rules/oj-compjson-syntax/ojcomp-FAIL_13/component.json +0 -17
- package/tests/rules/oj-compjson-syntax/ojcomp-FAIL_14/component.json +0 -40
- package/tests/rules/oj-compjson-syntax/ojcomp-FAIL_15/component.json +0 -24
- package/tests/rules/oj-compjson-syntax/ojcomp-FAIL_16/component.json +0 -44
- package/tests/rules/oj-compjson-syntax/ojcomp-FAIL_17/component.json +0 -8
- package/tests/rules/oj-compjson-syntax/ojcomp-FAIL_18/component.json +0 -8
- package/tests/rules/oj-compjson-syntax/ojcomp-FAIL_19/component.json +0 -8
- package/tests/rules/oj-compjson-syntax/ojcomp-FAIL_2/component.json +0 -15
- package/tests/rules/oj-compjson-syntax/ojcomp-FAIL_20/component.json +0 -18
- package/tests/rules/oj-compjson-syntax/ojcomp-FAIL_21/component.json +0 -16
- package/tests/rules/oj-compjson-syntax/ojcomp-FAIL_22/component.json +0 -19
- package/tests/rules/oj-compjson-syntax/ojcomp-FAIL_3/component.json +0 -15
- package/tests/rules/oj-compjson-syntax/ojcomp-FAIL_4/component.json +0 -16
- package/tests/rules/oj-compjson-syntax/ojcomp-FAIL_5/component.json +0 -16
- package/tests/rules/oj-compjson-syntax/ojcomp-FAIL_6/component.json +0 -18
- package/tests/rules/oj-compjson-syntax/ojcomp-FAIL_7/component.json +0 -15
- package/tests/rules/oj-compjson-syntax/ojcomp-FAIL_8/component.json +0 -15
- package/tests/rules/oj-compjson-syntax/ojcomp-FAIL_9/component.json +0 -52
- package/tests/rules/oj-compjson-syntax/ojcomp-PASS_1/component.json +0 -17
- package/tests/rules/oj-compjson-syntax/ojcomp-PASS_2/component.json +0 -88
- package/tests/rules/oj-compjson-syntax/ojcomp-PASS_3/component.json +0 -19
- package/tests/rules/oj-css-bp-dir-flow/dirflow_FAIL_1.html +0 -22
- package/tests/rules/oj-css-bp-dir-flow/dirflow_FAIL_2.html +0 -22
- package/tests/rules/oj-css-diagnose/css_FAIL_1.html +0 -14
- package/tests/rules/oj-css-diagnose/css_PASS_1.html +0 -14
- package/tests/rules/oj-css-var-override/varovr_FAIL_1.html +0 -8
- package/tests/rules/oj-html-5-attr-depr/attrdepr_FAIL_1.html +0 -16
- package/tests/rules/oj-html-5-attr-depr/attrdepr_PASS_1.html +0 -16
- package/tests/rules/oj-html-5-tag-depr/tagdepr_FAIL_1.html +0 -9
- package/tests/rules/oj-html-attr/attr_FAIL_1.html +0 -27
- package/tests/rules/oj-html-attr-$unique/attr_$unique1_FAIL_1.html +0 -19
- package/tests/rules/oj-html-attr-$unique/attr_$unique_FAIL_2.html +0 -25
- package/tests/rules/oj-html-attr-2def/attr2def_FAIL_1.html +0 -10
- package/tests/rules/oj-html-attr-2def/attr2def_PASS_1.html +0 -10
- package/tests/rules/oj-html-attr-json/attr-json_FAIL_1.html +0 -20
- package/tests/rules/oj-html-attr-json/attr-json_FAIL_2.html +0 -20
- package/tests/rules/oj-html-attr-json/attr-json_FAIL_3.html +0 -20
- package/tests/rules/oj-html-attr-json/attr-json_PASS_1.html +0 -20
- package/tests/rules/oj-html-attr-json/attr-json_PASS_2.html +0 -20
- package/tests/rules/oj-html-attr-json/attr-json_PASS_3.html +0 -8
- package/tests/rules/oj-html-attr-prefix-expr/attrprefixexpr_FAIL_1.html +0 -10
- package/tests/rules/oj-html-attr-prefix-expr/attrprefixexpr_PASS_1.html +0 -10
- package/tests/rules/oj-html-attr-prefix-ro/attrprefixro_FAIL_1.html +0 -10
- package/tests/rules/oj-html-attr-prefix-ro/attrprefixro_PASS_1.html +0 -10
- package/tests/rules/oj-html-attr-req/attrreq_FAIL_1.html +0 -17
- package/tests/rules/oj-html-attr-req/attrreq_FAIL_2.html +0 -13
- package/tests/rules/oj-html-attr-req/attrreq_FAIL_3.html +0 -8
- package/tests/rules/oj-html-attr-req/attrreq_FAIL_4.html +0 -13
- package/tests/rules/oj-html-attr-req/attrreq_FAIL_5.html +0 -17
- package/tests/rules/oj-html-attr-req/attrreq_PASS_1.html +0 -24
- package/tests/rules/oj-html-attr-req/attrreq_PASS_2.html +0 -24
- package/tests/rules/oj-html-attr-req/attrreq_PASS_3.html +0 -10
- package/tests/rules/oj-html-attr-req/attrreq_PASS_4.html +0 -11
- package/tests/rules/oj-html-bindforeach-data/bindforeach_data_FAIL_1.html +0 -19
- package/tests/rules/oj-html-bindforeach-data/bindforeach_data_PASS_1.html +0 -10
- package/tests/rules/oj-html-bindif-test/bindif_test_FAIL_1.html +0 -22
- package/tests/rules/oj-html-bindif-test/bindif_test_PASS_1.html +0 -11
- package/tests/rules/oj-html-binding-attr/binding-foreach_FAIL_2.html +0 -28
- package/tests/rules/oj-html-binding-attr/binding-if_FAIL_1.html +0 -23
- package/tests/rules/oj-html-binding-attr/binding-if_PASS_1.html +0 -23
- package/tests/rules/oj-html-cca-count/cca-count_FAIL_1.html +0 -119
- package/tests/rules/oj-html-cca-tagname/ccatag_FAIL_1.html +0 -7
- package/tests/rules/oj-html-cca-tagname/ccatag_PASS_1.html +0 -7
- package/tests/rules/oj-html-cca-tagname/tag_ns_FAIL_1.html +0 -8
- package/tests/rules/oj-html-cca-tagname/tag_ns_FAIL_2.html +0 -8
- package/tests/rules/oj-html-cca-tagname/tag_ns_FAIL_3.html +0 -8
- package/tests/rules/oj-html-cca-tagname/tag_ns_PASS_1.html +0 -10
- package/tests/rules/oj-html-cdn/html_cdn_FAIL_1.html +0 -18
- package/tests/rules/oj-html-cspexpr/cspexpr_FAIL_1.html +0 -14
- package/tests/rules/oj-html-cspexpr/cspexpr_FAIL_2.html +0 -10
- package/tests/rules/oj-html-cspexpr/cspexpr_PASS_1.html +0 -23
- package/tests/rules/oj-html-cspexpr/cspexpr_PASS_2.html +0 -10
- package/tests/rules/oj-html-cspexpr/cspexpr_PASS_3.html +0 -13
- package/tests/rules/oj-html-dlg-title/dlgtitle_FAIL_1.html +0 -12
- package/tests/rules/oj-html-dlg-title/dlgtitle_PASS_1.html +0 -12
- package/tests/rules/oj-html-form-noflex/noflex_FAIL_1.html +0 -10
- package/tests/rules/oj-html-invalid-doctype/doctype_invalid_FAIL_1.html +0 -20
- package/tests/rules/oj-html-invalid-doctype/doctype_invalid_FAIL_2.html +0 -13
- package/tests/rules/oj-html-invalid-doctype/doctype_invalid_FAIL_3.html +0 -16
- package/tests/rules/oj-html-invalid-doctype/doctype_invalid_FAIL_4.html +0 -13
- package/tests/rules/oj-html-invalid-doctype/doctype_invalid_PASS_1.html +0 -6
- package/tests/rules/oj-html-invalid-doctype/doctype_invalid_PASS_2.html +0 -7
- package/tests/rules/oj-html-invalid-doctype/doctype_invalid_PASS_3.html +0 -7
- package/tests/rules/oj-html-jq-databind/jq-databind_FAIL_1.html +0 -37
- package/tests/rules/oj-html-jq-databind/jq-databind_FAIL_2.html +0 -34
- package/tests/rules/oj-html-jq-databind/jq-databind_FAIL_3.html +0 -27
- package/tests/rules/oj-html-jq-databind/jq-databind_PASS_1.html +0 -30
- package/tests/rules/oj-html-ko-comment/ko-comment_FAIL_1.html +0 -47
- package/tests/rules/oj-html-ko-comment/ko-comment_FAIL_2.html +0 -36
- package/tests/rules/oj-html-ko-databind/ko-databind_FAIL_1.html +0 -24
- package/tests/rules/oj-html-ko-databind/ko-databind_FAIL_2.html +0 -36
- package/tests/rules/oj-html-ko-databind/ko-databind_FAIL_3.html +0 -29
- package/tests/rules/oj-html-label-for-prefix/for_FAIL_1.html +0 -8
- package/tests/rules/oj-html-label-for-prefix/for_PASS_1.html +0 -8
- package/tests/rules/oj-html-missing-doctype/doctype_missing_FAIL_1.html +0 -12
- package/tests/rules/oj-html-missing-doctype/doctype_missing_FAIL_2.html +0 -11
- package/tests/rules/oj-html-missing-doctype/doctype_missing_PASS_1.html +0 -14
- package/tests/rules/oj-html-missing-doctype/doctype_missing_PASS_2.html +0 -5
- package/tests/rules/oj-html-missing-doctype/doctype_missing_PASS_3.html +0 -12
- package/tests/rules/oj-html-missing-doctype/doctype_missing_PASS_5.html +0 -6
- package/tests/rules/oj-html-nonvoid-close/close_FAIL_1.html +0 -28
- package/tests/rules/oj-html-nonvoid-close/close_FAIL_2.html +0 -14
- package/tests/rules/oj-html-nonvoid-close/close_FAIL_3.html +0 -13
- package/tests/rules/oj-html-nonvoid-close/close_FAIL_5.html +0 -28
- package/tests/rules/oj-html-nonvoid-close/close_FAIL_6.html +0 -28
- package/tests/rules/oj-html-nonvoid-close/close_PASS_1.html +0 -7
- package/tests/rules/oj-html-oj-lib/oj_lib_FAIL_1.html +0 -15
- package/tests/rules/oj-html-ojattr/ojattr_PASS_1.html +0 -8
- package/tests/rules/oj-html-ojattr/ojattr_PASS_2.html +0 -10
- package/tests/rules/oj-html-ojattr/ojattr_PASS_3.html +0 -7
- package/tests/rules/oj-html-ojattr/ojattr_PASS_4.html +0 -7
- package/tests/rules/oj-html-ojattr-deprecated/ojattr-dep_FAIL1.html +0 -156
- package/tests/rules/oj-html-ojattr-enum-deprecated/enum_FAIL_1.html +0 -19
- package/tests/rules/oj-html-ojattr-enum-deprecated/enum_FAIL_2.html +0 -20
- package/tests/rules/oj-html-ojattr-enum-deprecated/enum_PASS_1.html +0 -25
- package/tests/rules/oj-html-ojattr-evt-syntax/evt-attr-syntax_FAIL_1.html +0 -6
- package/tests/rules/oj-html-ojattr-evt-syntax/evt-attr-syntax_PASS_1.html +0 -6
- package/tests/rules/oj-html-ojattr-value/attr-value_FAIL_1.html +0 -26
- package/tests/rules/oj-html-ojattr-value/attr-value_FAIL_2.html +0 -26
- package/tests/rules/oj-html-ojattr-value/attr-value_FAIL_3.html +0 -8
- package/tests/rules/oj-html-ojattr-value/attr-value_FAIL_4.html +0 -8
- package/tests/rules/oj-html-ojattr-value/attr-value_FAIL_5.html +0 -8
- package/tests/rules/oj-html-ojattr-value/attr-value_PASS_1.html +0 -26
- package/tests/rules/oj-html-ojattr-value/attr-value_PASS_2.html +0 -8
- package/tests/rules/oj-html-ojattr-value/attr-value_PASS_3.html +0 -7
- package/tests/rules/oj-html-ojattr-value/attr-value_PASS_6.html +0 -7
- package/tests/rules/oj-html-ojattr-value/attr-value_PASS_7.html +0 -10
- package/tests/rules/oj-html-ojattr-value/attr_value_PASS_4.html +0 -7
- package/tests/rules/oj-html-ojattr-value/attr_value_PASS_5.html +0 -9
- package/tests/rules/oj-html-ojslot/ojslot_FAIL_1.html +0 -11
- package/tests/rules/oj-html-ojslot/ojslot_PASS_1.html +0 -12
- package/tests/rules/oj-html-ojstyle/style_FAIL_1.html +0 -103
- package/tests/rules/oj-html-ojstyle/style_PASS_2.html +0 -7
- package/tests/rules/oj-html-ojtag-datacmd/datacmd_FAIL_1.html +0 -10
- package/tests/rules/oj-html-ojtag-datacmd/datacmd_FAIL_2.html +0 -18
- package/tests/rules/oj-html-ojtag-datacmd/datacmd_FAIL_3.html +0 -10
- package/tests/rules/oj-html-ojtag-datacmd/datacmd_PASS_1.html +0 -28
- package/tests/rules/oj-html-ojtag-datacmd/datacmd_PASS_2.html +0 -15
- package/tests/rules/oj-html-ojtag-datactx/datactx_FAIL_1.html +0 -14
- package/tests/rules/oj-html-ojtag-datactx/datactx_PASS_1.html +0 -14
- package/tests/rules/oj-html-ojtag-globattr-noprefix/globattr-noprefix_FAIL_1.html +0 -36
- package/tests/rules/oj-html-ojtag-nonglobattr-prefix/nonglobattr-prefix_FAIL_1.html +0 -26
- package/tests/rules/oj-html-slot-name/slot_name.FAIL_1.html +0 -24
- package/tests/rules/oj-html-slot-name/slot_name.FAIL_2.html +0 -46
- package/tests/rules/oj-html-slot-name/slot_name.FAIL_3.html +0 -10
- package/tests/rules/oj-html-slot-name/slot_name.PASS_1.html +0 -24
- package/tests/rules/oj-html-slot-name/slot_name.PASS_2.html +0 -39
- package/tests/rules/oj-html-slot-name/slot_name.PASS_3.html +0 -10
- package/tests/rules/oj-html-slot-name/slot_name_PASS_4.html +0 -16
- package/tests/rules/oj-html-slot-name/slot_name_PASS_5.html +0 -11
- package/tests/rules/oj-html-slot-name/slot_name_PASS_6.html +0 -14
- package/tests/rules/oj-html-slot-name/slot_name_PASS_7.html +0 -10
- package/tests/rules/oj-html-style/style_FAIL_1.html +0 -7
- package/tests/rules/oj-html-style/style_PASS_1.html +0 -12
- package/tests/rules/oj-html-style/style_PASS_2.html +0 -7
- package/tests/rules/oj-html-style-bp-color/color-FAIL_1.html +0 -17
- package/tests/rules/oj-html-style-bp-color/color-FAIL_2.html +0 -15
- package/tests/rules/oj-html-style-bp-color/color-FAIL_3.html +0 -7
- package/tests/rules/oj-html-style-bp-color/color-PASS_1.html +0 -7
- package/tests/rules/oj-html-style-bp-font-family/fam_FAIL_1.html +0 -23
- package/tests/rules/oj-html-tag-attr-noprefix/attr-noprefix_FAIL_1.html +0 -15
- package/tests/rules/oj-html-tag-attr-noprefix/attr-noprefix_FAIL_2.html +0 -9
- package/tests/rules/oj-html-tag-attr-noprefix/attr-noprefix_PASS_1.html +0 -9
- package/tests/rules/oj-html-unsup-theme/unsup_FAIL_1.html +0 -8
- package/tests/rules/oj-html-wctag-for/for_FAIL_1.html +0 -8
- package/tests/rules/oj-html-wctag-for/for_PASS_1.html +0 -8
- package/tests/rules/oj-js-comp-attr-deprecated/attr-del_FAIL_1.js +0 -20
- package/tests/rules/oj-js-comp-attr-deprecated/attr-dep_FAIL_1.js +0 -20
- package/tests/rules/oj-js-comp-meth-deprecated/meth-del_FAIL_1.js +0 -20
- package/tests/rules/oj-js-comp-meth-deprecated/meth-dep_FAIL_1.js +0 -20
- package/tests/rules/oj-js-define-promise/def-prom_FAIL_1.js +0 -16
- package/tests/rules/oj-js-define-promise/def-prom_FAIL_2.js +0 -16
- package/tests/rules/oj-js-diagnose/es6_PASS_1.js +0 -24
- package/tests/rules/oj-js-diagnose/js_FAIL_1.js +0 -12
- package/tests/rules/oj-js-no-ext-final/noextfinal_FAIL_1.js +0 -30
- package/tests/rules/oj-js-no-ext-final/noextfinal_FAIL_2.js +0 -23
- package/tests/rules/oj-js-no-ext-final/noextfinal_FAIL_3.js +0 -22
- package/tests/rules/oj-js-no-ext-final/noextfinal_FAIL_4.js +0 -20
- package/tests/rules/oj-js-no-ext-final/noextfinal_FAIL_5.js +0 -24
- package/tests/rules/oj-js-no-ext-final/noextfinal_FAIL_6.js +0 -30
- package/tests/rules/oj-js-no-ext-final/noextfinal_FAIL_7.js +0 -15
- package/tests/rules/oj-js-no-ext-final/noextfinal_FAIL_8.js +0 -16
- package/tests/rules/oj-js-no-ext-final/noextfinal_PASS_1.js +0 -17
- package/tests/rules/oj-js-no-ext-final/noextfinal_PASS_2.js +0 -17
- package/tests/rules/oj-js-noconsole/nocons_FAIL_1.js +0 -11
- package/tests/rules/oj-js-ojcomp-deprecated/jscomp_FAIL_1.js +0 -27
- package/tests/rules/oj-json-syntax/json_FAIL_1.json +0 -8
- package/tests/rules/oj-json-syntax/json_FAIL_2.json +0 -12
- package/tests/rules/oj-json-syntax/json_PASS_1.json +0 -25
- package/tests/rules/oj-json-syntax/json_PASS_2.json +0 -12
- package/tests/rules/oj-json-syntax/json_PASS_3.json +0 -14
- package/tests/rules/ojcompjson/attrreq_FAIL_1/component.json +0 -69
- package/tests/rules/pack-compjson/audit-pack/component-1/component-1-view.html +0 -6
- package/tests/rules/pack-compjson/audit-pack/component-1/component-1-viewModel.js +0 -56
- package/tests/rules/pack-compjson/audit-pack/component-1/component.json +0 -13
- package/tests/rules/pack-compjson/audit-pack/component-1/loader.js +0 -20
- package/tests/rules/pack-compjson/audit-pack/component-1/resources/nls/component-1-strings.js +0 -18
- package/tests/rules/pack-compjson/audit-pack/component-2/component-2-view.html +0 -5
- package/tests/rules/pack-compjson/audit-pack/component-2/component-2-viewModel.js +0 -56
- package/tests/rules/pack-compjson/audit-pack/component-2/component.json +0 -13
- package/tests/rules/pack-compjson/audit-pack/component-2/loader.js +0 -20
- package/tests/rules/pack-compjson/audit-pack/component-2/resources/nls/component-1-strings.js +0 -18
- package/tests/rules/pack-compjson/audit-pack/component.json +0 -12
- package/tests/rules/pack-compjson/audit-singleton-1/audit-singleton-1-view.html +0 -5
- package/tests/rules/pack-compjson/audit-singleton-1/audit-singleton-1-viewModel.js +0 -56
- package/tests/rules/pack-compjson/audit-singleton-1/component.json +0 -20
- package/tests/rules/pack-compjson/audit-singleton-1/loader.js +0 -20
- package/tests/rules/pack-compjson/audit-singleton-1/resources/nls/audit-singleton-1-strings.js +0 -18
- package/tests/rules/pack-compjson/audit-singleton-2/audit-singleton-2-view.html +0 -8
- package/tests/rules/pack-compjson/audit-singleton-2/audit-singleton-2-viewModel.js +0 -56
- package/tests/rules/pack-compjson/audit-singleton-2/component.json +0 -15
- package/tests/rules/pack-compjson/audit-singleton-2/loader.js +0 -20
- package/tests/rules/pack-compjson/audit-singleton-2/resources/nls/audit-singleton-2-strings.js +0 -18
- package/tests/rules/parse-html/proc_instr.html +0 -9
- package/tests/rules/spoc-dom-manip/dom-manip_FAIL_1.js +0 -113
- package/tests/rules/spoc-dom-manip/dom-manip_FAIL_2.js +0 -151
- package/tests/rules/spoc-dom-manip/dom-manip_PASS_1.js +0 -149
- package/tests/rules/spoc-dom-manip/dom-manip_PASS_2.js +0 -147
- package/tests/rules/spoc-dom-manip/dom-manip_PASS_3.js +0 -147
- package/tests/rules/spoc-dom-manip/dom-manip_PASS_4.js +0 -20
- package/tests/rules/spoc-dom-manip/dom-manip_PASS_5.js +0 -246
- package/tests/rules/tab-tests/tab-test_FAIL_1.html +0 -37
- package/tests/rules/tab-tests/tab-test_FAIL_2.html +0 -8
- package/tests/rules/webcomptests/jet-composites/oj-html-wctag-$props/prop_PASS_1.html +0 -8
- package/tests/rules/webcomptests/jet-composites/oj-html-wctag-$props/prop_PASS_2.html +0 -8
- package/tests/rules/webcomptests/jet-composites/oj-html-wctag-for/for_FAIL_1.html +0 -8
- package/tests/rules/webcomptests/jet-composites/oj-html-wctag-for/for_PASS_1.html +0 -8
- package/tests/src/JetTest.js +0 -1
- package/tests/src/server.js +0 -1
- package/tests/test.js +0 -1
|
@@ -1 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2018, 2021, Oracle and/or its affiliates.
|
|
3
|
+
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
|
+
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
|
+
*/
|
|
6
|
+
{"title":"Extended Audit Rules for JET Custom Component Authors","prefix":"JETWC","version":"1.10.0","rules":{"jetwc-bootstrap":{"group":"jetwc-do-not-disable","enabled":true,"severity":"info","debug":false,"diagnosticFile":"jetwc-diagnostics","componentRoot":"jet-composites","auditBuildOutput":false,"testMode":false},"jetwc-component-foldername":{"group":"jetwc-structure","severity":"blocker","filetype":["json","tsx"]},"jetwc-component-location":{"group":"jetwc-structure","severity":"blocker","filetype":["json","tsx"]},"jetwc-pack-children":{"group":"jetwc-dependencies","severity":"blocker","filetype":["json"]},"jetwc-packable-components":{"group":"jetwc-structure","severity":"blocker","filetype":["json"]},"jetwc-component-dependencies":{"group":"jetwc-dependencies","severity":"blocker","filetype":["json","tsx"]},"jetwc-prerelease-version":{"group":"jetwc-pre-release","severity":"info","filetype":["json","tsx"]},"jetwc-prerelease-dependencies":{"group":"jetwc-pre-release","severity":"info","filetype":["json","tsx"]},"jetwc-namespace":{"group":"jetwc-api","enabled":false,"namespaces":[],"severity":"blocker","filetype":["json","tsx"]},"jetwc-vb-category":{"group":"jetwc-vb","enabled":false,"categories":[],"severity":"minor","filetype":["json","tsx"]},"jetwc-jet-version":{"group":"jetwc-pre-release","enabled":false,"versionMatch":"upperLimit","severity":"blocker","filetype":["json","tsx"]},"jetwc-absolute-jetversion":{"group":"jetwc-dependencies","enabled":true,"severity":"minor","filetype":["json","tsx"]},"jetwc-semantic-version":{"group":"jetwc-dependencies","severity":"blocker","filetype":["json","tsx"]},"jetwc-standard-files":{"group":"jetwc-structure","enabled":true,"files":["README.md","CHANGELOG.md"],"severity":"info","filetype":["json","tsx"]},"jetwc-loader-file":{"group":["jetwc-structure","jet-js"],"enabled":true,"severity":"critical","filetype":["json","js","ts","tsx"]},"jetwc-version-openrange":{"group":"jetwc-dependencies","severity":"major","filetype":["json","tsx"]},"jetwc-displayname":{"group":"jetwc-vb","enabled":true,"limits":{"component":{"length":30,"words":4},"property":{"length":30,"words":4},"event":{"length":30,"words":4},"template":{"length":40,"words":8}},"severity":"info","filetype":["json","tsx"]},"jetwc-nls-root":{"group":"jetwc-nls","enabled":true,"severity":"info","filetype":["js","ts","tsx"]},"jetwc-require-paths":{"group":"jetwc-dependencies","enabled":true,"severity":"blocker","standardPaths":["require","exports","ojs","knockout","hammerjs","persist","jquery","vb","preact"],"filetype":["js","ts","tsx"]},"jetwc-vb-icon":{"group":"jetwc-vb","enabled":true,"severity":"major","filetype":["json","tsx"]},"jetwc-template-slots":{"group":"jetwc-api","enabled":true,"severity":"major","filetype":["html","tsx"]},"jetwc-slots":{"group":"jetwc-api","enabled":true,"severity":"major","filetype":["html","tsx"]},"jetwc-events":{"group":"jetwc-api","enabled":true,"severity":"major","filetype":["js","ts","tsx"]},"jetwc-property-nesting":{"group":"jetwc-api","enabled":true,"depth":3,"severity":"minor","filetype":["json"]},"jetwc-nls-languages":{"group":"jetwc-nls","enabled":false,"locales":[],"strict":false,"severity":"major","filetype":["js","ts","tsx"]},"jetwc-event-displayname":{"group":"jetwc-vb","enabled":true,"severity":"info","filetype":["json","tsx"]},"jetwc-nested-defaults":{"group":"jetwc-api","enabled":true,"severity":"major","filetype":["json","tsx"]},"jetwc-methods":{"group":"jetwc-api","enabled":true,"severity":"blocker","filetype":["js","ts"]},"jetwc-property-changed":{"group":"jetwc-api","enabled":true,"severity":"minor","filetype":["js","ts"]},"jetwc-writeback-required":{"group":"jetwc-api","enabled":true,"severity":"major","filetype":["js","ts"]},"jetwc-oj-register":{"group":"jetwc-deprecations","enabled":true,"severity":"minor","filetype":["js","ts"]},"jetwc-register-with-promises":{"group":"jetwc-deprecations","enabled":true,"severity":"minor","filetype":["js","ts"]},"jetwc-register-css":{"group":"jetwc-deprecations","enabled":true,"severity":"minor","filetype":["js","ts"]},"jetwc-deprecated-lifecycle":{"group":"jetwc-deprecations","enabled":true,"severity":"major","filetype":["js","ts"]},"jetwc-aria-redefinition":{"group":"jetwc-api","enabled":true,"severity":"minor","filetype":["json"]},"jetwc-public-modules":{"group":"jetwc-api","enabled":true,"severity":"major","filetype":["json"]},"jetwc-disabled-property":{"group":"jetwc-api","enabled":true,"severity":"minor","filetype":["json"]},"jetwc-reserved-property":{"group":"jetwc-api","enabled":true,"severity":"major","reserved":["slot","key","ref","children"],"filetype":["json","tsx"]},"jetwc-prerelease-pattern":{"group":"jetwc-api","enabled":true,"severity":"minor","filetype":["json","tsx"]},"jetwc-ojcss":{"group":"jetwc-theming","enabled":true,"severity":"minor","filetype":["js","ts","tsx"]},"jetwc-dynamic-slot-context":{"group":"jetwc-api","enabled":true,"severity":"major","filetype":["json"]},"jetwc-dynamic-slots-naming":{"group":"jetwc-api","enabled":true,"severity":"minor","filetype":["json"]},"jetwc-unused-slots":{"group":"jetwc-api","enabled":true,"severity":"info","filetype":["html"]},"jetwc-unused-events":{"group":"jetwc-api","enabled":true,"severity":"info","filetype":["js","ts"]},"jetwc-compjson-bp-obj":{"group":"jetwc-api","enabled":true,"severity":"info","filetype":["json"]},"jetwc-compjson-bp-ar":{"group":"jetwc-api","enabled":true,"severity":"info","filetype":["json"]},"jetwc-component-displayname":{"group":"jetwc-vb","enabled":true,"severity":"info","filetype":["json"]},"jetwc-method-displayname":{"group":"jetwc-vb","enabled":true,"severity":"info","filetype":["json"]},"jetwc-property-displayname":{"group":"jetwc-vb","enabled":true,"severity":"info","filetype":["json"]},"jetwc-slot-displayname":{"group":"jetwc-vb","enabled":true,"severity":"info","filetype":["json"]},"jetwc-data-property-prefix":{"group":"jetwc-api","enabled":true,"severity":"minor","filetype":["json"]},"jetwc-schema":{"group":"jetwc-api","enabled":true,"severity":"blocker","filetype":["json"]},"jetwc-component-type":{"group":"jetwc-api","enabled":true,"severity":"info","filetype":["json"]},"jetwc-subproperty-writeback":{"group":"jetwc-api","enabled":true,"severity":"major","filetype":["html"]},"jetwc-required-subproperty":{"group":"jetwc-api","enabled":true,"severity":"minor","filetype":["json"]}}}
|
|
@@ -1 +1,6 @@
|
|
|
1
|
-
const path=require('path');const Utils=function(){this.rootPoint=path.resolve('.').length+1;this.jaf28plus;this.isWindows=path.sep!=='/';this.noJSWarnDone=false};Utils.prototype.matchComponentPath=function(context,checkPathBase,recursion){let checkPath=checkPathBase;let componentMatch;if(context.rulePack.getExtension().allAuditableFilePaths.has(checkPath)){const x=context.rulePack.getExtension().allAuditableFilePaths;componentMatch=context.rulePack.getExtension().allAuditableFilePaths.get(checkPath)}else if(checkPath.includes(context.rulePack.getExtension().componentHome)){if(context.rulePack.getExtension().auditableComponentPaths.has(checkPath)){componentMatch=context.rulePack.getExtension().auditableComponentPaths.get(checkPath)}else{const parentPath=this.toJAFPath(path.resolve(checkPath,'../'));componentMatch=this.matchComponentPath(context,parentPath,true)}if(!recursion){context.rulePack.getExtension().allAuditableFilePaths.set(checkPath,componentMatch)}}else{context.rulePack.getExtension().allAuditableFilePaths.set(checkPath)}return componentMatch};Utils.prototype.componentInfo=function(context,componentName){return context.rulePack.getExtension().allComponents.get(componentName)};Utils.prototype.getComponentFullName=function(metadata){return metadata.pack?`${metadata.pack}-${metadata.name}`:metadata.name};Utils.prototype.getComponentType=function(metadata){return metadata.type?metadata.type:'composite'};Utils.prototype.isExpressionString=function(value){if(value){const bindingExpr=/^(?:\[{2})(.*)(?:\]{2})$|^(?:\{{2})(.*)(?:\}{2})$/g;return bindingExpr.test(value.trim())}return false};Utils.prototype.setupFileMethodMapping=function(context,node){const fileName=context.filepath;const withinComponent=this.matchComponentPath(context,path.dirname(fileName));if(withinComponent){if(node.parent&&node.parent.type==='AssignmentExpression'&&node.parent.operator==='='){if(node.parent.left&&node.parent.left.property&&node.parent.left.property.type=='Identifier'&&node.parent.left.property.name){const methodDef={name:node.parent.left.property.name,parameters:node.params?node.params.length:0};this.cacheFileMethod(context,fileName,methodDef)}}else if(node.parent&&node.parent.type==='MethodDefinition'&&node.parent.kind==='method'){if(node.parent.key&&node.parent.key.name){const methodDef={name:node.parent.key.name,parameters:node.params?node.params.length:0};this.cacheFileMethod(context,fileName,methodDef)}}}};Utils.prototype.cacheFileMethod=function(context,filePath,methodDef){if(!context.rulePack.getExtension().allDefinedFileMethods){context.rulePack.getExtension().allDefinedFileMethods=new Map}if(!context.rulePack.getExtension().allDefinedFileMethods.has(filePath)){context.rulePack.getExtension().allDefinedFileMethods.set(filePath,{methods:new Map})}if(!context.rulePack.getExtension().allDefinedFileMethods.get(filePath).methods.has(methodDef.name)){context.rulePack.getExtension().allDefinedFileMethods.get(filePath).methods.set(methodDef.name,methodDef)}};Utils.prototype.deriveViewModels=function(context,node){const fileName=context.filepath;const withinComponent=this.matchComponentPath(context,path.dirname(fileName));const componentInfo=context.rulePack.getExtension().allComponents.get(withinComponent);if(withinComponent&&componentInfo&&componentInfo.type==='composite'&&componentInfo.language==='js'&&!componentInfo.viewModel.resolved&&path.basename(fileName,'.js')==='loader'){const registerInfo=this.getLoaderRegisterInfo(node);if(registerInfo){const vmRelativeFilePath=this._mapVMToImpl(node,registerInfo.viewModel);if(vmRelativeFilePath){const fullVMPath=this.expandPathInContext(context,withinComponent,vmRelativeFilePath);if(fullVMPath){componentInfo.viewModel={path:path.resolve('.',fullVMPath+'.js'),resolved:true,skip:false}}}}}};Utils.prototype.getLoaderRegisterInfo=function(node){let registerInfo;if(node.callee.type='MemberExpression'&&node.callee.object&&node.arguments&&node.arguments.length>0){let isRegister=false;let oldStyle=false;switch(node.callee.object.type){case'Identifier':if(node.callee.object.name==='Composite'){isRegister=this._astPropertyIdentifierName(node.callee,'register')}break;case'MemberExpression':if(node.callee.property&&node.callee.property.type==='Identifier'&&node.callee.property.name==='register'){if(this._astPropertyIdentifierName(node.callee.object,'Composite')){isRegister=node.callee.object.object&&node.callee.object.object.type==='Identifier'&&node.callee.object.object.name==='oj';if(isRegister){oldStyle=true}}}break;}if(isRegister){registerInfo={oldStyle:oldStyle};const tagArg=node.arguments[0];const def=node.arguments[1];registerInfo.tag=tagArg.type==='Literal'?tagArg.value:'?';if(def.type==='ObjectExpression'){vmProp=def.properties.filter(prop=>prop.key.name==='viewModel');if(vmProp.length===1){switch(vmProp[0].value.type){case'Identifier':registerInfo.viewModel=vmProp[0].value.name;break;case'ObjectExpression':if(vmProp[0].value.properties&&vmProp[0].value.properties[0]&&vmProp[0].value.properties[0].key.name==='inline'){registerInfo.viewModel=vmProp[0].value.properties[0].value.name;registerInfo.usesPromises=true}break;case'MemberExpression':if(vmProp[0].value.property&&vmProp[0].value.property.type==='Identifier'){registerInfo.viewModel=vmProp[0].value.object.name;registerInfo.transpiled=true}break;}}const cssCheck=def.properties.filter(prop=>prop.key.name==='css');if(cssCheck.length>0){registerInfo.registerCSS=true}}}}return registerInfo};Utils.prototype._astPropertyIdentifierName=function(node,checkName){return node&&node.property&&node.property.type==='Identifier'&&node.property.name===checkName};Utils.prototype._mapVMToImpl=function(node,vmName){let vmPathDef;if(vmName){let rootNode=node;let defineIndex=this._mapVMToDefineIndex(rootNode,vmName);if(!isNaN(defineIndex)){vmPathDef=this._getDefineStatementElement(node,defineIndex)}else{vmPathDef=this._mapToRequireAssignment(node,vmName)}}return vmPathDef};Utils.prototype._mapVMToDefineIndex=function(node,vmName){let checkNode=node.parent;let defineIndex;let found=false;while(checkNode){if(checkNode.type==='FunctionExpression'&&checkNode.params){for(let i=0;i<checkNode.params.length;i++){if(checkNode.params[i].name===vmName){defineIndex=i;found=true;break}}}if(!found){checkNode=checkNode.parent}else{break}}return defineIndex};Utils.prototype._mapToRequireAssignment=function(node,vmName){let requirePath;const vmDeclNode=this._locateDeclaration(node,vmName);if(vmDeclNode.type==='CallExpression'&&vmDeclNode.callee.type==='Identifier'&&vmDeclNode.callee.name==='require'){if(vmDeclNode.arguments&&vmDeclNode.arguments.length===1&&vmDeclNode.arguments[0].type==='Literal'){requirePath=vmDeclNode.arguments[0].value}}return requirePath};Utils.prototype._getDefineStatementElement=function(node,defineIndex){let checkNode=node.parent;let definePath;while(checkNode){if(checkNode.type==='CallExpression'&&checkNode.callee.name==='define'){if(checkNode.arguments&&checkNode.arguments.length===2){if(checkNode.arguments[0].type==='ArrayExpression'){if(checkNode.arguments[0].elements.length>=defineIndex){definePath=checkNode.arguments[0].elements[defineIndex].value;break}}}}checkNode=checkNode.parent}return definePath};Utils.prototype.expandPathInContext=function(context,componentName,requirePath){let targetPath=requirePath;const parsePluginParts=requirePath.split('!');if(parsePluginParts.length>1){targetPath=parsePluginParts[1]}let pathParts=targetPath.split('/');const decodeRoot=pathParts[0];if(decodeRoot==='.'){pathParts[0]=this.rootPathForComponent(context,componentName)}else{const remotePart=this.rootPathForComponent(context,decodeRoot);if(!remotePart){pathParts=[]}else{pathParts[0]=remotePart}}return pathParts.join('/')};Utils.prototype.rootPathForComponent=function(context,componentName){if(context.rulePack.getExtension().allComponents.has(componentName)){return context.rulePack.getExtension().allComponents.get(componentName).rootFolder}};Utils.prototype.getVMMethodsForLocalComposite=function(context,component){let vmMethods;if(component.local&&component.type==='composite'&&component.language==='js'){if(!component.viewModel.skip){if(!component.viewModel.resolved&&!component.viewModel.warned){console.log(`Warning: unable to derive the correct viewModel implementation for component ${component.fullName}, either your audit run does not include .js files, or you may need to set 'extension.audit.jetwc.viewModel' in the metadata to provide a hint`);component.viewModel.warned=true}else{const rpState=context.rulePack.getExtension();if(rpState.allDefinedFileMethods&&rpState.allDefinedFileMethods.size>0){const vmMethodDef=rpState.allDefinedFileMethods.get(component.viewModel.path);if(vmMethodDef){vmMethods=vmMethodDef.methods}}else{if(!this.noJSWarnDone){console.log('Error: No JavaScript files have been processed. You need to ensure that your audit fileset includes .js, html and .json files to enable all audits in thisC rule-set. Use the ojaf --dryrun command to determine what files are covered by the audit');this.noJSWarnDone=true}}}}}return vmMethods};Utils.prototype.decomposeAssignment=function(assignmentNode){const breakdown=[];this._walkAssignmentNodes(assignmentNode.left,breakdown);if(!breakdown.includes('this')){const parentAssignment=breakdown[breakdown.length-1];const initialAssignmentNode=this._locateDeclaration(assignmentNode,parentAssignment);if(initialAssignmentNode){if(initialAssignmentNode==='<parameter>'){breakdown.push('<parameter>')}else if(initialAssignmentNode.type==='ThisExpression'){breakdown.push('this')}else if(initialAssignmentNode.type==='Identifier'){breakdown.push(initialAssignmentNode.name);const indirectAssignmentNode=this._locateDeclaration(assignmentNode,initialAssignmentNode.name);if(indirectAssignmentNode==='<parameter>'){breakdown.push('<parameter>')}else if(indirectAssignmentNode.type==='ThisExpression'){breakdown.push('this')}}}}return breakdown};Utils.prototype._walkAssignmentNodes=function(node,accumulator){switch(node.type){case'MemberExpression':accumulator.push(node.property.name);if(node.object){this._walkAssignmentNodes(node.object,accumulator)}break;case'Identifier':accumulator.push(node.name);break;case'ThisExpression':accumulator.push('this');break;}};Utils.prototype._locateDeclaration=function(node,searchVariable){let initialAssignment;let workingNode=node;while(!initialAssignment){if(workingNode.body&&workingNode.body.length>0){workingNode.body.forEach(bodyNode=>{if(bodyNode.type==='VariableDeclaration'){bodyNode.declarations.forEach(declNode=>{if(declNode.id.type==='Identifier'&&declNode.id.name===searchVariable){initialAssignment=declNode.init}})}})}else if(workingNode.params&&workingNode.params.length>0){workingNode.params.forEach(paramNode=>{if(paramNode.name===searchVariable){initialAssignment='<parameter>'}})}if(!workingNode.parent){break}else{workingNode=workingNode.parent}}return initialAssignment};Utils.prototype.extractComponentInfoFromJSONFile=function(auditContext,componentFolder,fileName,isLocal){let componentInfo={};const mdFile=this.toJAFPath(path.join(componentFolder,fileName));const compMetadata=auditContext.utils.fsUtils.readJsonSync(mdFile);if(compMetadata!==null){componentInfo.fullName=compMetadata.pack?`${compMetadata.pack}-${compMetadata.name}`:compMetadata.name;componentInfo.pack=compMetadata.pack;componentInfo.name=compMetadata.name;componentInfo.version=compMetadata.version;componentInfo.type=compMetadata.type?compMetadata.type:'composite';componentInfo.local=isLocal;componentInfo.rootFolder=this.toJAFPath(componentFolder);componentInfo.requirePaths=new Set;switch(componentInfo.type){case'reference':if(compMetadata.extension&&compMetadata.extension.oracle&&compMetadata.extension.oracle.businessApprovals){componentInfo.ba=compMetadata.extension.oracle.businessApprovals}if(compMetadata.paths&&compMetadata.paths.name){componentInfo.requirePaths.add(compMetadata.paths.name)}else{const extractPathSegments=compMetadata.package.split('/');if(extractPathSegments.length>1){componentInfo.requirePaths.add(extractPathSegments[1])}else{componentInfo.requirePaths.add(extractPathSegments[0])}}break;case'composite':if(compMetadata.slots){componentInfo.slots=compMetadata.slots}if(compMetadata.properties){componentInfo.properties=compMetadata.properties}if(compMetadata.events){componentInfo.events=compMetadata.events}if(compMetadata.methods&&Object.keys(compMetadata.methods).length>0){componentInfo.methods=compMetadata.methods}componentInfo.viewModel={resolved:false};if(compMetadata&&compMetadata.extension&&compMetadata.extension.audit&&compMetadata.extension.audit.jetwc&&compMetadata.extension.audit.jetwc.hasOwnProperty('viewModel')){const overrideVM=compMetadata.extension.audit.jetwc.viewModel;if(overrideVM){componentInfo.viewModel={path:this.toJAFPath(path.resolve('.',componentInfo.rootFolder,overrideVM)),resolved:true,skip:false}}else{componentInfo.viewModel={skip:true}}}case'resource':componentInfo.requirePaths.add('.');if(compMetadata.pack){componentInfo.requirePaths.add(`${compMetadata.pack}/${compMetadata.name}`)}else{componentInfo.requirePaths.add(compMetadata.name)}if(compMetadata.dependencies){componentInfo.dependencies=Object.keys(compMetadata.dependencies)}break;}return componentInfo}else{console.error(`Error Invalid JSON in component metadata ${mdFile}, component ignored`)}return};Utils.prototype.diagnosticReplacer=function(key,value){if(value instanceof Map){return Array.from(value).map(([vKey,vValue])=>{return{[vKey]:vValue?vValue:''}})}if(value instanceof Set){return Array.from(value)}return value};Utils.prototype.toJAFPath=function(sourcePath){if(this.isWindows){return sourcePath.replace(/\\\\|\\/g,'/')}return sourcePath};Utils.prototype.getDirectoryName=function(filePath){return path.dirname(filePath)};Utils.prototype.shouldIgnoreCheck=function(context,auditName,componentName,scope,target){let ignore=false;const checkComponentDef=context.rulePack.getExtension().allComponents.get(componentName);if(checkComponentDef&&checkComponentDef[scope]){let targetDef;if(target.includes('.')&&scope==='properties'){targetDef=this.getPropertyAttributeFromPath(context,componentName,target)}else{targetDef=checkComponentDef[scope][target==='__default__'?'':target]}if(targetDef.hasOwnProperty('extension')&&targetDef.extension.hasOwnProperty('audit')&&targetDef.extension.audit.hasOwnProperty('ignore')){const ignoreArray=targetDef.extension.audit.ignore;ignore=ignoreArray.includes(auditName)}}return ignore};Utils.prototype.getPropertyAttributeFromPath=function(context,componentName,targetPath,attribute){const checkComponentDef=context.rulePack.getExtension().allComponents.get(componentName);let targetDef;if(checkComponentDef&&checkComponentDef.properties){if(targetPath.includes('.')){const propPath=targetPath.split('.');targetDef=checkComponentDef.properties[propPath[0]];for(let i=1;i<propPath.length;i++){targetDef=targetDef.properties[propPath[i]]}}else{targetDef=checkComponentDef.properties[targetPath]}}if(attribute){return targetDef[attribute]}else{return targetDef}};module.exports=new Utils;
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2018, 2021, Oracle and/or its affiliates.
|
|
3
|
+
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
|
+
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
|
+
*/
|
|
6
|
+
const path=require('path');const Utils=function(){this.rootPoint=this.toJAFPath(path.resolve('.')).length+1;this.isWindows=path.sep!=='/';this.noJSWarnDone=false};Utils.prototype.getKeyPathInfoForRulepack=function(context,auditBase){const paths={isBuiltOutput:false,componentRootFolder:null,exchangeCacheFolder:null,generalSourceRoot:'src',jsSource:null,tsSource:null};let jetConfig=context.ojetConfig;if(!jetConfig&&auditBase){const remoteConfig=path.join(auditBase,'oraclejetconfig.json');if(context.utils.fsUtils.pathExistsSync(remoteConfig)){jetConfig=context.utils.fsUtils.readJsonSync(remoteConfig)}}let jsDir='js';let tsDir='ts';paths.isBuiltOutput=context.rulePack.getRuleOptions().auditBuildOutput;if(jetConfig){jsDir=jetConfig.paths.source.javascript||'js';tsDir=jetConfig.paths.source.typescript||'ts';paths.exchangeCacheFolder=jetConfig.paths.source.exchangeComponents||'jet_components';paths.componentRootFolder=jetConfig.paths.source.components||'jet-composites';if(!paths.isBuiltOutput){paths.generalSourceRoot=jetConfig.paths.source.common||'src'}else{paths.generalSourceRoot=jetConfig.paths.staging.web||'web'}}paths.jsSource=this.toJAFPath(path.join(paths.generalSourceRoot,jsDir));if(!paths.isBuiltOutput){paths.tsSource=this.toJAFPath(path.join(paths.generalSourceRoot,tsDir))}return paths};Utils.prototype.matchComponentPath=function(context,checkPathBase,recursion){let checkPath=checkPathBase;let componentMatch;if(context.rulePack.getExtension()&&context.rulePack.getExtension().hasOwnProperty('allAuditableFilePaths')){if(context.rulePack.getExtension().allAuditableFilePaths.has(checkPath)){const x=context.rulePack.getExtension().allAuditableFilePaths;componentMatch=context.rulePack.getExtension().allAuditableFilePaths.get(checkPath)}else if(checkPath.includes(context.rulePack.getExtension().componentHome)){if(context.rulePack.getExtension().auditableComponentPaths.has(checkPath)){componentMatch=context.rulePack.getExtension().auditableComponentPaths.get(checkPath)}else{const parentPath=this.toJAFPath(path.resolve(checkPath,'..'+path.sep));componentMatch=this.matchComponentPath(context,parentPath,true)}if(!recursion){context.rulePack.getExtension().allAuditableFilePaths.set(checkPath,componentMatch)}}else{context.rulePack.getExtension().allAuditableFilePaths.set(checkPath)}}else{this.reportMissingBootstrapInfo(context,'allAuditableFilePaths')}return componentMatch};Utils.prototype.reportMissingBootstrapInfo=function(context,checkTopic){const extnContext=context.rulePack.getExtension();if(!extnContext||!extnContext.bootStrap){const bootstrapRule=context.rulePack.getPrefix().toLowerCase()+'-bootstrap';if(context.rulePack.isRuleDisabled(bootstrapRule)){console.error(`ERROR: You must enable the ${bootstrapRule} rule to run in order to carry out a full component set audit`)}else{console.error(`ERROR: Apparent bootstrap error, no information cached for ${checkTopic}`)}context.rulePack.setExtension({...extnContext,bootStrap:true})}};Utils.prototype.componentInfo=function(context,componentName){if(context.rulePack.getExtension()&&context.rulePack.getExtension().hasOwnProperty('allComponents')){return context.rulePack.getExtension().allComponents.get(componentName)}else{this.reportMissingBootstrapInfo(context,'allComponents')}return};Utils.prototype.getComponentFullName=function(metadata){return metadata.pack?`${metadata.pack}-${metadata.name}`:metadata.name};Utils.prototype.getComponentType=function(metadata){return metadata.type?metadata.type:'composite'};Utils.prototype.isExpressionString=function(value){if(value){const bindingExpr=/^(?:\[{2})(.*)(?:\]{2})$|^(?:\{{2})(.*)(?:\}{2})$/g;return bindingExpr.test(value.trim())}return false};Utils.prototype.setupFileMethodMapping=function(context,node){const fileName=context.filepath;const withinComponent=this.matchComponentPath(context,path.dirname(fileName));if(withinComponent){if(node.parent&&node.parent.type==='AssignmentExpression'&&node.parent.operator==='='){if(node.parent.left&&node.parent.left.property&&node.parent.left.property.type=='Identifier'&&node.parent.left.property.name){const methodDef={name:node.parent.left.property.name,parameters:node.params?node.params.length:0};this.cacheFileMethod(context,fileName,methodDef)}}else if(node.parent&&node.parent.type==='MethodDefinition'&&node.parent.kind==='method'){if(node.parent.key&&node.parent.key.name){const methodDef={name:node.parent.key.name,parameters:node.params?node.params.length:0};this.cacheFileMethod(context,fileName,methodDef)}}else if(node.parent&&node.parent.type==='ClassProperty'){if(node.parent.key&&node.parent.key.name){const methodDef={name:node.parent.key.name,parameters:node.params?node.params.length:0};this.cacheFileMethod(context,fileName,methodDef)}}}};Utils.prototype.setupFileMethodMappingFromMethodDefintion=function(context,node){const NT=context.utils.AstUtils.getNodeTypes();const fileName=context.filepath;const withinComponent=this.matchComponentPath(context,path.dirname(fileName));if(withinComponent){const methodDef={parameters:0};if(node.key&&node.key.type===NT.IDENTIFIER){methodDef.name=node.key.name;if(node.value&&node.value.type===NT.FUNC_EXPR&&node.value.params){methodDef.parameters=node.value.params.length}}if(methodDef.name){this.cacheFileMethod(context,fileName,methodDef)}}};Utils.prototype.cacheFileMethod=function(context,filePath,methodDef){if(!context.rulePack.getExtension().allDefinedFileMethods){context.rulePack.getExtension().allDefinedFileMethods=new Map}if(!context.rulePack.getExtension().allDefinedFileMethods.has(filePath)){context.rulePack.getExtension().allDefinedFileMethods.set(filePath,{methods:new Map})}if(!context.rulePack.getExtension().allDefinedFileMethods.get(filePath).methods.has(methodDef.name)){context.rulePack.getExtension().allDefinedFileMethods.get(filePath).methods.set(methodDef.name,methodDef)}};Utils.prototype.deriveViewModels=function(context,node){const fileName=context.filepath;if(context.rulePack.getExtension()&&context.rulePack.getExtension().hasOwnProperty('allComponents')){const withinComponent=this.matchComponentPath(context,path.dirname(fileName));const componentInfo=context.rulePack.getExtension().allComponents.get(withinComponent);if(withinComponent&&componentInfo&&componentInfo.type==='composite'&&!componentInfo.viewModel.resolved){const targetLoaderExt=componentInfo.language==='tsx'?'.ts':`.${componentInfo.language}`;if(path.basename(fileName,targetLoaderExt)==='loader'){switch(componentInfo.language){case'js':case'ts':const registerInfo=this.getLoaderRegisterInfo(context,node);if(registerInfo){const vmRelativeFilePath=this._mapVMToImpl(context,node,registerInfo.viewModel,componentInfo.language==='ts');if(vmRelativeFilePath){const fullVMPath=this._expandPathInContext(context,withinComponent,vmRelativeFilePath);if(fullVMPath){componentInfo.viewModel={path:this.toJAFPath(path.resolve('.',`${fullVMPath}.${componentInfo.language}`)),resolved:true,skip:false}}}}break;case'tsx':break;}}}}else{this.reportMissingBootstrapInfo(context,'allComponents')}};Utils.prototype.getLoaderRegisterInfo=function(context,node){const NT=context.utils.AstUtils.getNodeTypes();let registerInfo;if(node.callee.type=NT.MEMBER_EXPR&&node.callee.object&&node.arguments&&node.arguments.length>0){let isRegister=false;let oldStyle=false;switch(node.callee.object.type){case NT.IDENTIFIER:if(node.callee.object.name==='Composite'){isRegister=this._astPropertyIdentifierName(node.callee,'register')}break;case NT.MEMBER_EXPR:if(node.callee.property&&node.callee.property.type===NT.IDENTIFIER&&node.callee.property.name==='register'){if(this._astPropertyIdentifierName(node.callee.object,'Composite')){isRegister=node.callee.object.object&&node.callee.object.object.type===NT.IDENTIFIER&&node.callee.object.object.name==='oj';if(isRegister){oldStyle=true}}}break;}if(isRegister){registerInfo={oldStyle:oldStyle};const tagArg=node.arguments[0];const def=node.arguments[1];registerInfo.tag=tagArg.type===NT.LITERAL?tagArg.value:'?';if(def.type===NT.OBJ_EXPR){vmProp=def.properties.filter(prop=>prop.key.name==='viewModel');if(vmProp.length===1){switch(vmProp[0].value.type){case NT.IDENTIFIER:registerInfo.viewModel=vmProp[0].value.name;break;case NT.OBJ_EXPR:if(vmProp[0].value.properties&&vmProp[0].value.properties[0]&&vmProp[0].value.properties[0].key.name==='inline'){registerInfo.viewModel=vmProp[0].value.properties[0].value.name;registerInfo.usesPromises=true}break;case NT.MEMBER_EXPR:if(vmProp[0].value.property&&vmProp[0].value.property.type===NT.IDENTIFIER){registerInfo.viewModel=vmProp[0].value.object.name;registerInfo.transpiled=true}break;case'TSAsExpression':if(vmProp[0].value.expression&&vmProp[0].value.expression.type===NT.IDENTIFIER){registerInfo.viewModel=vmProp[0].value.expression.name}else if(vmProp[0].value.expression&&vmProp[0].value.expression.type==='TSAsExpression'){registerInfo.viewModel=vmProp[0].value.expression.expression.name;console.warn(`WARNING: Component loader file ${context.filepath} attempts to redefine the composite.register viewModel interface`)}break;}}const cssCheck=def.properties.filter(prop=>prop.key.name==='css');if(cssCheck.length>0){registerInfo.registerCSS=true}}}}return registerInfo};Utils.prototype._astPropertyIdentifierName=function(node,checkName){return node&&node.property&&node.property.type==='Identifier'&&node.property.name===checkName};Utils.prototype._mapVMToImpl=function(context,node,vmName,useImports){let vmPathDef;if(vmName){let rootNode=node;if(useImports){vmPathDef=this._getImportPath(context,rootNode,vmName)}else{vmPathDef=this._getDefineStatementPath(context,rootNode,vmName);if(!vmPathDef){vmPathDef=this._mapToRequireAssignment(node,vmName)}}}return vmPathDef};Utils.prototype._mapToRequireAssignment=function(node,vmName){let requirePath;const vmDeclNode=this._locateDeclaration(node,vmName);if(vmDeclNode.type==='CallExpression'&&vmDeclNode.callee.type==='Identifier'&&vmDeclNode.callee.name==='require'){if(vmDeclNode.arguments&&vmDeclNode.arguments.length===1&&vmDeclNode.arguments[0].type==='Literal'){requirePath=vmDeclNode.arguments[0].value}}return requirePath};Utils.prototype._getImportPath=function(context,node,importAs){const NT=context.utils.AstUtils.getNodeTypes();const bodyNodeArray=context.utils.AstUtils.getBody();let definePath;for(let i=0;i<bodyNodeArray.length;i++){const testNode=bodyNodeArray[i];switch(testNode.type){case'ImportDeclaration':if(testNode.specifiers&&Array.isArray(testNode.specifiers)&&testNode.specifiers.length===1&&(testNode.specifiers[0].type==='ImportDefaultSpecifier'||testNode.specifiers[0].type==='ImportSpecifier')&&testNode.specifiers[0].local&&testNode.specifiers[0].local.name===importAs){definePath=testNode.source.value}break;case'TSImportEqualsDeclaration':if(testNode.id&&testNode.id.type===NT.IDENTIFIER&&testNode.id.name===importAs&&testNode.moduleReference&&testNode.moduleReference.type==='TSExternalModuleReference'&&testNode.moduleReference.expression&&testNode.moduleReference.expression.type===NT.LITERAL){definePath=testNode.moduleReference.expression.value}break;}if(definePath){;break}}return definePath};Utils.prototype._getDefineStatementPath=function(context,node,defineParam){const NT=context.utils.AstUtils.getNodeTypes();let checkNode=node.parent;let definePath;while(checkNode){if(checkNode.type===NT.CALL_EXPR&&checkNode.callee.name==='define'){definePath=context.utils.AstUtils.parseDefine(checkNode)[defineParam]}checkNode=checkNode.parent}return definePath};Utils.prototype._expandPathInContext=function(context,componentName,requirePath){let targetPath=requirePath;const parsePluginParts=requirePath.split('!');if(parsePluginParts.length>1){targetPath=parsePluginParts[1]}let pathParts=targetPath.split('/');const decodeRoot=pathParts[0];if(decodeRoot==='.'){pathParts[0]=this.rootPathForComponent(context,componentName)}else{const remotePart=this.rootPathForComponent(context,decodeRoot);if(!remotePart){pathParts=[]}else{pathParts[0]=remotePart}}return pathParts.join('/')};Utils.prototype.rootPathForComponent=function(context,componentName){if(context.rulePack.getExtension().allComponents.has(componentName)){return context.rulePack.getExtension().allComponents.get(componentName).rootFolder}};Utils.prototype.getVMMethodsForLocalComposite=function(context,component){let vmMethods;const opts=context.rulePack.getRuleOptions();if(component.local&&component.type==='composite'){if(!component.viewModel.skip){if(!component.viewModel.resolved&&!component.viewModel.warned){if(!opts.testMode){console.log(`Warning: unable to derive the correct viewModel implementation for component ${component.fullName}, either your audit run does not include .js/.ts files, or you may need to set 'extension.audit.jetwc.viewModel' in the metadata to provide a hint`)}component.viewModel.warned=true}else{const rpState=context.rulePack.getExtension();if(rpState.allDefinedFileMethods&&rpState.allDefinedFileMethods.size>0){const vmMethodDef=rpState.allDefinedFileMethods.get(component.viewModel.path);if(vmMethodDef){vmMethods=vmMethodDef.methods}}else{if(!this.noJSWarnDone){console.log('Error: No JavaScript / TypeScript files have been processed. You need to ensure that your audit fileset includes .js, .ts, html and .json files to enable all audits in this rule-set. Use the ojaf --dryrun command to determine what files are covered by the audit');this.noJSWarnDone=true}}}}}return vmMethods};Utils.prototype.decomposeAssignment=function(assignmentNode){const breakdown=[];this._walkAssignmentNodes(assignmentNode.left,breakdown);if(!breakdown.includes('this')){const parentAssignment=breakdown[breakdown.length-1];const initialAssignmentNode=this._locateDeclaration(assignmentNode,parentAssignment);if(initialAssignmentNode){if(initialAssignmentNode==='<parameter>'){breakdown.push('<parameter>')}else if(initialAssignmentNode.type==='ThisExpression'){breakdown.push('this')}else if(initialAssignmentNode.type==='Identifier'){breakdown.push(initialAssignmentNode.name);const indirectAssignmentNode=this._locateDeclaration(assignmentNode,initialAssignmentNode.name);if(indirectAssignmentNode==='<parameter>'){breakdown.push('<parameter>')}else if(indirectAssignmentNode.type==='ThisExpression'){breakdown.push('this')}}}}return breakdown};Utils.prototype._walkAssignmentNodes=function(node,accumulator){switch(node.type){case'MemberExpression':accumulator.push(node.property.name);if(node.object){this._walkAssignmentNodes(node.object,accumulator)}break;case'Identifier':accumulator.push(node.name);break;case'ThisExpression':accumulator.push('this');break;}};Utils.prototype._locateDeclaration=function(node,searchVariable){let initialAssignment;let workingNode=node;while(!initialAssignment){if(workingNode.body&&workingNode.body.length>0){workingNode.body.forEach(bodyNode=>{if(bodyNode.type==='VariableDeclaration'){bodyNode.declarations.forEach(declNode=>{if(declNode.id.type==='Identifier'&&declNode.id.name===searchVariable){initialAssignment=declNode.init}})}})}else if(workingNode.params&&workingNode.params.length>0){workingNode.params.forEach(paramNode=>{if(paramNode.name===searchVariable){initialAssignment='<parameter>'}})}if(!workingNode.parent){break}else{workingNode=workingNode.parent}}return initialAssignment};Utils.prototype.extractComponentInfoFromJSONFile=function(auditContext,componentFolder,fileName,isLocal){let componentInfo={};const mdFile=this.toJAFPath(path.join(componentFolder,fileName));const compMetadata=auditContext.utils.fsUtils.readJsonSync(mdFile);if(compMetadata!==null){componentInfo.fullName=this.getComponentFullName(compMetadata);componentInfo.pack=compMetadata.pack;componentInfo.name=compMetadata.name;componentInfo.version=compMetadata.version;componentInfo.extension=compMetadata.extension;componentInfo.type=compMetadata.type?compMetadata.type:'composite';componentInfo.local=isLocal;componentInfo.rootFolder=this.toJAFPath(componentFolder);componentInfo.requirePaths=new Set;switch(componentInfo.type){case'reference':if(compMetadata.extension&&compMetadata.extension.oracle&&compMetadata.extension.oracle.businessApprovals){componentInfo.ba=compMetadata.extension.oracle.businessApprovals}if(compMetadata.paths&&compMetadata.paths.name){componentInfo.requirePaths.add(compMetadata.paths.name)}else{const extractPathSegments=compMetadata.package.split('/');if(extractPathSegments.length>1){componentInfo.requirePaths.add(extractPathSegments[1])}else{componentInfo.requirePaths.add(extractPathSegments[0])}}break;case'composite':if(compMetadata.slots){componentInfo.slots=compMetadata.slots}if(compMetadata.properties){componentInfo.properties=compMetadata.properties}if(compMetadata.events){componentInfo.events=compMetadata.events}if(compMetadata.methods&&Object.keys(compMetadata.methods).length>0){componentInfo.methods=compMetadata.methods}componentInfo.viewModel={resolved:false};if(compMetadata&&compMetadata.extension&&compMetadata.extension.audit&&compMetadata.extension.audit.jetwc&&compMetadata.extension.audit.jetwc.hasOwnProperty('viewModel')){const overrideVM=compMetadata.extension.audit.jetwc.viewModel;if(overrideVM){componentInfo.viewModel={path:this.toJAFPath(path.resolve('.',componentInfo.rootFolder,overrideVM)),resolved:true,skip:false}}else{componentInfo.viewModel={skip:true}}}case'resource':componentInfo.requirePaths.add('.');if(compMetadata.pack){componentInfo.requirePaths.add(`${compMetadata.pack}/${compMetadata.name}`)}else{componentInfo.requirePaths.add(compMetadata.name)}if(compMetadata.dependencies){componentInfo.dependencies=Object.keys(compMetadata.dependencies)}break;}return componentInfo}else{console.error(`Error Invalid JSON in component metadata ${mdFile}, component ignored`)}return};Utils.prototype.diagnosticReplacer=function(key,value){if(value instanceof Map){return Array.from(value).map(([vKey,vValue])=>{return{[vKey]:vValue?vValue:''}})}if(value instanceof Set){return Array.from(value)}return value};Utils.prototype.toJAFPath=function(sourcePath){if(this.isWindows){return sourcePath.replace(/\\\\|\\/g,'/')}return sourcePath};Utils.prototype.getDirectoryName=function(filePath){return path.dirname(filePath)};Utils.prototype.shouldIgnoreCheck=function(context,auditName,componentName,scope,target){let ignore=false;const checkComponentDef=context.rulePack.getExtension().allComponents.get(componentName);if(checkComponentDef){let targetDef;if(scope&&checkComponentDef[scope]){if(target.includes('.')&&scope==='properties'){targetDef=this.getPropertyAttributeFromPath(context,componentName,target)}else{targetDef=checkComponentDef[scope][target==='__default__'?'':target]}}else{targetDef=checkComponentDef}if(targetDef&&targetDef.extension&&targetDef.extension.hasOwnProperty('audit')&&targetDef.extension.audit.hasOwnProperty('ignore')){const ignoreArray=targetDef.extension.audit.ignore;ignore=ignoreArray.includes(auditName)}}return ignore};Utils.prototype.getPropertyAttributeFromPath=function(context,componentName,targetPath,attribute){const checkComponentDef=context.rulePack.getExtension().allComponents.get(componentName);let targetDef;if(checkComponentDef&&checkComponentDef.properties){if(targetPath.includes('.')){const propPath=targetPath.split('.');targetDef=checkComponentDef.properties[propPath[0]];for(let i=1;i<propPath.length;i++){targetDef=targetDef.properties[propPath[i]]}}else{targetDef=checkComponentDef.properties[targetPath]}}if(attribute){return targetDef[attribute]}else{return targetDef}};Utils.prototype.detectComponentSourceType=function(context,componentPathRoot){const fs=context.utils.fsUtils;let componentImplType;if(fs.fileExistsSync(path.join(componentPathRoot,'loader.js'))){componentImplType='js'}else if(fs.fileExistsSync(path.join(componentPathRoot,'loader.ts'))){componentImplType=this._lookForTSorTSX(context,componentPathRoot)}else{const pathSegs=componentPathRoot.toLowerCase().split('/');if(pathSegs.includes('ts')){componentImplType=this._lookForTSorTSX(context,componentPathRoot)}else{componentImplType='js'}}return componentImplType};Utils.prototype._lookForTSorTSX=function(context,searchFolder,files){const fs=context.utils.fsUtils;let detectedType;let folderContents;if(!files){folderContents=fs.readDirSync(searchFolder)}else{folderContents=files}let fileCount=folderContents.length;let i=0;do{if(folderContents[i].isFile){const extn=fs.getFileExtSync(folderContents[i].name).toLowerCase();if(extn==='tsx'){detectedType='tsx';break}else if(extn==='ts'){detectedType='ts'}}else{const folderDrillType=this._lookForTSorTSX(context,null,folderContents[i].files);if(folderDrillType==='tsx'){detectedType='tsx';break}else if(folderDrillType==='ts'){detectedType='ts'}}i++}while(i<fileCount);return detectedType};Utils.prototype.getComponentCacheFolderName=function(context){return`jaftmp@-${context.rulePack.getPrefix()}`};Utils.prototype.ensureLocalCache=function(context){const cacheFolder=this.getComponentCacheFolderName(context);if(!context.utils.fsUtils.pathExistsSync(cacheFolder)){context.utils.fsUtils.createFolderSync(cacheFolder)}};Utils.prototype.removeLocalCache=function(context){const cacheFolder=this.getComponentCacheFolderName(context);if(context.utils.fsUtils.pathExistsSync(cacheFolder)){context.utils.fsUtils.deleteFolderSync(cacheFolder,true)}};Utils.prototype.generateComponentCachePath=function(context,component,componentVersion){const cacheFolder=this.getComponentCacheFolderName(context);const mungedVersion=componentVersion.replace(/\./g,'-');return path.join(cacheFolder,`${component}@${mungedVersion}-component.json`)};Utils.prototype.existsInComponentCache=function(context,component,componentVersion){const cacheFile=this.generateComponentCachePath(context,component,componentVersion);return context.utils.fsUtils.fileExistsSync(cacheFile)};Utils.prototype.writeToComponentCache=function(context,component,componentVersion,metadata){if(metadata){const cacheFile=this.generateComponentCachePath(context,component,componentVersion);context.utils.fsUtils.writeJsonSync(metadata,cacheFile)}};Utils.prototype.readFromComponentCache=function(context,component,componentVersion){let readMetadata;const cacheFile=this.generateComponentCachePath(context,component,componentVersion);return context.utils.fsUtils.readJsonSync(cacheFile)};Utils.prototype.getObjectHashSignature=function(sourceObject){const sourceAsStringArray=Array.from(JSON.stringify(sourceObject));return sourceAsStringArray.reduce((hash,c)=>Math.imul(31,hash)+c.charCodeAt(0)|0,0)};Utils.prototype.safeSetExtension=function(context,extnValue){let existingContext=context.rulePack.getExtension();if(!existingContext){existingContext={}}const newContext={...existingContext,...extnValue};context.rulePack.setExtension(newContext)};module.exports=new Utils;
|
|
@@ -1 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2018, 2021, Oracle and/or its affiliates.
|
|
3
|
+
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
|
+
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
|
+
*/
|
|
6
|
+
const path=require('path');const Utils=require('../jetwc-lib/component-audit-utils');const ruleDef=function(){};ruleDef.prototype.getName=function(){return'jetwco-bootstrap'};ruleDef.prototype.getShortDescription=function(){return'Bootstrap processing for the JETWCO rulset'};ruleDef.prototype.getDescription=function(){return'This rule is for internal use by the ruleset and should not be disabled'};ruleDef.prototype.register=function(context){this.componentRoots=context.config.components;this.auditBase=context.config.base;return{startupRP:this._getAllVisibleComponents,closedownRP:this._reportDiagnostics}};ruleDef.prototype._getAllVisibleComponents=function(context){console.info(`${context.rulePack.getPackInfo().prefix} : ${context.rulePack.getPackInfo().version}`);let masterComponentList=[];const projectPathInfo=Utils.getKeyPathInfoForRulepack(context,this.auditBase);if(projectPathInfo.exchangeCacheFolder){masterComponentList=masterComponentList.concat(this._getComponents(projectPathInfo.exchangeCacheFolder,false,false,context))}if(this.componentRoots&&this.componentRoots.length>0){this.componentRoots.forEach(root=>{masterComponentList=masterComponentList.concat(this._getComponents(root,true,projectPathInfo.isBuiltOutput,context))})}else{masterComponentList=masterComponentList.concat(this._getComponents(projectPathInfo.jsSource,true,projectPathInfo.isBuiltOutput,context));if(projectPathInfo.tsSource){masterComponentList=masterComponentList.concat(this._getComponents(projectPathInfo.tsSource,true,false,context))}}const componentRootFolder=context.rulePack.getRuleOptions().componentRoot||projectPathInfo.componentRootFolder;const allComponentsMap=masterComponentList.reduce((wmap,component)=>{if(!projectPathInfo.isBuiltOutput||projectPathInfo.isBuiltOutput&&!wmap.has(component.fullName)){wmap.set(component.fullName,component)}return wmap},new Map);const referenceComponents=new Map;const componentPaths=new Map;allComponentsMap.forEach(component=>{component.language=Utils.detectComponentSourceType(context,component.rootFolder);switch(component.type){case'reference':referenceComponents.set(component.fullName,component.ba);break;case'composite':case'resource':if(component.local){if(component.dependencies){Object.values(component.dependencies).forEach(dependencyName=>{if(allComponentsMap.has(dependencyName)){const proxyPaths=allComponentsMap.get(dependencyName).requirePaths;proxyPaths.forEach(path=>{component.requirePaths.add(path)})}})}componentPaths.set(component.rootFolder,component.fullName)}break;}});context.rulePack.setExtension({rulepackVersion:context.rulePack.getPackInfo().version,bootStrap:true,platform:Utils.isWindows?'Windows':'Unix-like',componentHome:`/${componentRootFolder}/`,auditBuildOutput:projectPathInfo.isBuiltOutput,discoveredPaths:projectPathInfo,componentRoots:this.componentRoots,allReferenceComponents:referenceComponents,allComponents:allComponentsMap,auditableComponentPaths:componentPaths,allAuditableFilePaths:new Map})};ruleDef.prototype._getComponents=function(rootDir,isLocal,builtOutput,auditContext){let componentArray=[];if(auditContext.utils.fsUtils.pathExistsSync(rootDir)){const compFileStructure=auditContext.utils.fsUtils.readDir(rootDir);compFileStructure.forEach(l1file=>{let componentInfo;if(!l1file.isFile&&l1file.files.length>0){l1file.files.forEach(l2file=>{if(!builtOutput){if(l2file.isFile&&l2file.name==='component.json'){componentInfo=Utils.extractComponentInfoFromJSONFile(auditContext,path.join(rootDir,l1file.name),'component.json',isLocal);componentArray.push(componentInfo);if(componentInfo.type==='pack'){const packMembers=this._getComponents(Utils.toJAFPath(path.join(rootDir,l1file.name)),isLocal,false,auditContext);componentArray=componentArray.concat(packMembers)}}}else{if(!l2file.isFile&&l2file.files.length>0){l2file.files.forEach(l3file=>{if(l3file.isFile&&l3file.name==='component.json'){componentInfo=Utils.extractComponentInfoFromJSONFile(auditContext,path.join(rootDir,l1file.name,l2file.name),'component.json',isLocal);if(!componentInfo.pack){componentArray.push(componentInfo);if(componentInfo.type==='pack'){const packMembers=this._getComponents(Utils.toJAFPath(path.join(rootDir,l1file.name,l2file.name)),isLocal,false,auditContext);componentArray=componentArray.concat(packMembers)}}}})}}})}else{if(l1file.isFile&&l1file.name==='component.json'){componentInfo=Utils.extractComponentInfoFromJSONFile(auditContext,rootDir,'component.json',isLocal);if(componentInfo.type!=='pack'){componentArray.push(componentInfo)}}}})}return componentArray};ruleDef.prototype._reportDiagnostics=function(context){const opts=context.rulePack.getRuleOptions();const cache=context.rulePack.getExtension();if(opts.debug&&opts.diagnosticFile){console.log(`Writing JETWCO diagnostics to ${opts.diagnosticFile}.json`);const dFile=Utils.toJAFPath(path.join(path.resolve('.'),opts.diagnosticFile+'.json'));context.utils.fsUtils.writeJsonSync(context.rulePack.getExtension(),dFile,{spaces:2,replacer:Utils.diagnosticReplacer})}};module.exports=ruleDef;
|
|
@@ -1 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2018, 2021, Oracle and/or its affiliates.
|
|
3
|
+
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
|
+
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
|
+
*/
|
|
6
|
+
const Utils=require('../jetwc-lib/component-audit-utils');const ruleDef=function(){};ruleDef.prototype.getName=function(){return'jetwco-compjson-ns-reg'};ruleDef.prototype.getShortDescription=function(){return'Web component namespaces starting with \'oj-\' or \'ns-\' must be registered.'};ruleDef.prototype.getDescription=function(){return'Web components namespaces starting with prefixes \'oj-\' or \'ns-\' must be registered. A component must not use an un-registered namespace.'};ruleDef.prototype.register=function(context){return{compjson:this._doAudit}};ruleDef.prototype._doAudit=function(context){if(!context.rulePack.isRuleEnabled('oj-cca-compjson-ns-reg','JET')){if(context.suppData.obj){const meta=context.suppData.obj;const componentName=Utils.getComponentFullName(meta);if(componentName&&!context.utils.metaLib.isJetTag(componentName)&&(componentName.startsWith('oj-')||componentName.startsWith('ns-'))){const nameParts=componentName.split('-');if(nameParts.length>1){const checkNS=nameParts[0]+'-'+nameParts[1];if(!context.utils.metaLib.isNSRegistered(checkNS)){const issue=new context.Issue(`${componentName}: unregistered use of the '${nameParts[0]}' namespace`);issue.setPosition(this._getNamePos(context.suppData.ast));context.reporter.addIssue(issue,context,'major')}}}}}};ruleDef.prototype._getNamePos=function(ast){var props,name,pos,ret=null,i;if(ast&&ast.members){props=ast.members;for(i=0;i<props.length;i++){name=props[i];if(name.name==='name'){pos=name.pos;ret={line:pos.row,col:pos.col,startIndex:pos.index,endIndex:pos.index+5};break}}}return ret};module.exports=ruleDef;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2018, 2021, Oracle and/or its affiliates.
|
|
3
|
+
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
|
+
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
|
+
*/
|
|
6
|
+
const Utils=require('../jetwc-lib/component-audit-utils');const NetUtils=require('../../lib/NetUtils');const path=require('path');const EXCHANGEROOT='https://exchange.oraclecorp.com/api/0.2.0/components/';const ruleDef=function(){};ruleDef.prototype.getName=function(){return'jetwco-component-api-baseline-changes'};ruleDef.prototype.getShortDescription=function(){return'Check components for API changes against a base version'};ruleDef.prototype.getDescription=function(){return'This audit compares the APIs exposed by components with a designated baseline version of a component in the Exchange Catalog and checks if the component APIs have changed'};ruleDef.prototype.register=function(context){return{startupRP:this._prepareBaselineData,closedownRP:this._dealWithCache,compjson:this._doAudit}};ruleDef.prototype._prepareBaselineData=function(context){let baselineConfigured=false;let baselineMetadata=[];Utils.ensureLocalCache(context);const baselineOpt=context.rulePack.getRuleOption('baseline','jetwco-component-api-baseline-changes');if(baselineOpt){const baselineHash=Utils.getObjectHashSignature(baselineOpt);const cacheIndexFile=path.join(Utils.getComponentCacheFolderName(context),`${baselineHash}.json`);let baselineIndex={};if(context.utils.fsUtils.fileExistsSync(cacheIndexFile)){baselineIndex=context.utils.fsUtils.readJsonSync(cacheIndexFile)}else{for(const[baselineComponent,baselineComponentVersion]of Object.entries(baselineOpt)){const eachComponent=this._cacheBaselineMetadataForComponent(baselineComponent,baselineComponentVersion);baselineMetadata=baselineMetadata.concat(eachComponent)}baselineMetadata.forEach(component=>{const fullName=Utils.getComponentFullName(component);baselineIndex[fullName]=component.version;if(!Utils.existsInComponentCache(context,fullName,component.version)){Utils.writeToComponentCache(context,fullName,component.version,component)}});context.utils.fsUtils.writeJsonSync(baselineIndex,cacheIndexFile)}baselineConfigured=true;if(Object.keys(baselineIndex).length>0){Utils.safeSetExtension(context,{baselineIndex:baselineIndex})}}return baselineConfigured};ruleDef.prototype._cacheBaselineMetadataForComponent=function(componentName,componentVersion){let componentMetaArray=[];try{const netUtils=new NetUtils;const componentMetaResp=netUtils.loadUrl(`${EXCHANGEROOT}${componentName}/versions/${componentVersion}`);if(componentMetaResp.statusCode=200&&componentMetaResp.body){const componentResponseMeta=JSON.parse(componentMetaResp.body);const componentMeta=componentResponseMeta.component;if(componentMeta){const compType=componentMeta.type?componentMeta.type:'composite';if(compType==='pack'){const dependents=componentMeta.dependencies;if(dependents){for(const[packComponent,packComponentVersion]of Object.entries(dependents)){const eachPackMember=this._cacheBaselineMetadataForComponent(packComponent,packComponentVersion);componentMetaArray=componentMetaArray.concat(eachPackMember)}}}componentMetaArray.push(componentMeta)}}}catch(e){console.log(JSON.stringify(e))};return componentMetaArray};ruleDef.prototype._dealWithCache=function(context){const shouldClearCache=context.rulePack.getRuleOption('clearCache','jetwco-component-api-baseline-changes');if(shouldClearCache){Utils.removeLocalCache(context)}};ruleDef.prototype._doAudit=function(context){const componentMeta=context.suppData.obj;if(componentMeta){const baselineIndex=context.rulePack.getExtension().baselineIndex;const componentType=Utils.getComponentType(componentMeta);const fullName=Utils.getComponentFullName(componentMeta);const componentVersion=componentMeta.version;const baselineVersion=baselineIndex[fullName];if(baselineVersion){const semver=context.utils.semVerUtils;const baselineComponentMeta=Utils.readFromComponentCache(context,fullName,baselineVersion);try{switch(componentType){case'pack':this._conductCheck(this._packContentsDiff,componentMeta,baselineComponentMeta);this._conductCheck(this._packBundlesDiff,componentMeta,baselineComponentMeta);break;case'composite':this._conductCheck(this._detectJetVersionDiff,semver,componentMeta,baselineComponentMeta);this._conductCheck(this._detectDependencyDiff,semver,componentMeta,baselineComponentMeta);this._conductCheck(this._detectMethodDiff,componentMeta,baselineComponentMeta);this._conductCheck(this._detectEventDiff,componentMeta,baselineComponentMeta);this._conductCheck(this._detectSlotDiff,componentMeta,baselineComponentMeta);this._conductCheck(this._detectDynamicSlotDiff,componentMeta,baselineComponentMeta);this._conductCheck(this._detectPropertyDiff,componentMeta,baselineComponentMeta);break;case'vbcs-pattern':this._conductCheck(this._detectDependencyDiff,semver,componentMeta,baselineComponentMeta);break;case'resource':this._conductCheck(this._detectJetVersionDiff,semver,componentMeta,baselineComponentMeta);this._conductCheck(this._detectDependencyDiff,semver,componentMeta,baselineComponentMeta);this._conductCheck(this._detectPublicModulesDiff,componentMeta,baselineComponentMeta);break;}}catch(auditDetail){const issue=new context.Issue(`API change for ${fullName}@${componentVersion} detected in comparison with baseline version ${baselineVersion}. Indication: ${auditDetail}`);context.reporter.addIssue(issue,context,'blocker')}}}};ruleDef.prototype._conductCheck=function(checkCallback,semver,config,existingConfig){const result=checkCallback.call(this,semver,config,existingConfig);if(result){throw result}};ruleDef.prototype._detectJetVersionDiff=function(semver,config,existingConfig,claimedMinorDiff){let explanation;const componentJetVersion=config.jetVersion?config.jetVersion:'0.0.0';const existingJetVersion=existingConfig.jetVersion?existingConfig.jetVersion:'0.0.0';if(componentJetVersion!==existingJetVersion){if(existingJetVersion==='0.0.0'||componentJetVersion==='0.0.0'){explanation='JET version range has been added or removed'}else{const minVersion=semver.minVersion(componentJetVersion);const minExistingVersion=semver.minVersion(existingJetVersion);if(semver.major(minVersion)>semver.major(minExistingVersion)){explanation='minimum major JET version required has increased'}else if(semver.minor(minVersion)>semver.minor(minExistingVersion)){explanation='minimum minor JET version required has increased'}}}return explanation};ruleDef.prototype._packContentsDiff=function(config,existingConfig){let explanation;const configDeps=config.dependencies?Object.keys(config.dependencies):[];const existingDeps=existingConfig.dependencies?Object.keys(existingConfig.dependencies):[];if(configDeps.length>0){for(let i=0;i<existingDeps.length;i++){const key=existingDeps[i];if(!config.dependencies.hasOwnProperty(key)){explanation=`Pack component ${key} has been removed`;break}}}return explanation};ruleDef.prototype._packBundlesDiff=function(config,existingConfig){let explanation;const configBundles=config.bundles?Object.keys(config.bundles):[];const existingBundles=existingConfig.bundles?Object.keys(existingConfig.bundles):[];for(let i=0;i<existingBundles.length;i++){const key=existingBundles[i];if(!config.bundles.hasOwnProperty(key)){explanation=`Pack bundle '${key}' has been removed`;break}else{const configContents=config.bundles[key];const existingContents=existingConfig.bundles[key];for(let i=0;i<existingContents.length;i++){const module=existingContents[i];if(!configContents.includes(module)){explanation=`Pack bundle '${key}' entry '${module}' removed`;break}}}}return explanation};ruleDef.prototype._detectPublicModulesDiff=function(config,existingConfig){let explanation;const configPM=config.publicModules?config.publicModules:[];const existingPM=existingConfig.publicModules?existingConfig.publicModules:[];for(let i=0;i<existingPM.length;i++){const module=existingPM[i];if(!configPM.includes(module)){explanation=`Public Module entry '${module}' has been removed`;break}}return explanation};ruleDef.prototype._detectDependencyDiff=function(semver,config,existingConfig){let explanation;const configDeps=config.dependencies?Object.keys(config.dependencies):[];const existingDeps=existingConfig.dependencies?Object.keys(existingConfig.dependencies):[];if(configDeps.length>existingDeps.length){explanation='More dependencies are declared by component'}else{if(configDeps.length>0){for(let i=0;i<existingDeps.length;i++){const key=existingDeps[i];if(config.dependencies.hasOwnProperty(key)){const newDepVersion=semver.minVersion(config.dependencies[key]);const existingDepVersion=semver.minVersion(existingConfig.dependencies[key]);if(semver.major(newDepVersion)!==semver.major(existingDepVersion)){explanation='Different major version of dependency '+key;break}if(semver.minor(newDepVersion)!==semver.minor(existingDepVersion)){explanation='Different minor version of dependency '+key;break}}else{explanation=`Dependency ${key} has been removed`;break}}}}return explanation};ruleDef.prototype._detectMethodDiff=function(config,existingConfig){let explanation;const configMethods=config.methods?Object.keys(config.methods):[];const existingMethods=existingConfig.methods?Object.keys(existingConfig.methods):[];for(let i=0;i<existingMethods.length;i++){const key=existingMethods[i];if(config.methods.hasOwnProperty(key)){const configMethodParams=config.methods[key].params?config.methods[key].params:[];const existingMethodParams=existingConfig.methods[key].params?existingConfig.methods[key].params:[];for(let j=0;j<existingMethodParams.length;j++){if(j>=configMethodParams.length){explanation=`Existing method '${key}' has fewer parameters`;break}else{if(!this._compareType(configMethodParams[j],existingMethodParams[j])){explanation=`Method '${key}' parameter number:${j+1} has a changed type`;break}}}if(!explanation&&configMethodParams.length>existingMethodParams.length){explanation=`Existing method '${key}' has additional parameters`;break}}else{explanation=`Existing method '${key}' has been removed`;break}}return explanation};ruleDef.prototype._detectPropertyDiff=function(config,existingConfig){let explanation;const configProps=config.properties?Object.keys(config.properties):[];const existingProps=existingConfig.properties?Object.keys(existingConfig.properties):[];explanation=this._compareProperties(config.properties,existingConfig.properties);if(!explanation){const addedRequiredProps=configProps.filter(addedProp=>!existingProps.includes(addedProp)&&config[addedProp].required);if(addedRequiredProps.length>0){explanation=`Required property(ies) added: ${addedRequiredProps.join(',')}`}}return explanation};ruleDef.prototype._detectEventDiff=function(config,existingConfig){let explanation;const configEvents=config.events?Object.keys(config.events):[];const existingEvents=existingConfig.events?Object.keys(existingConfig.events):[];for(let i=0;i<existingEvents.length;i++){const key=existingEvents[i];if(config.events.hasOwnProperty(key)){const configEventDetail=config.events[key].detail?config.events[key].detail:{};const existingEventDetail=existingConfig.events[key].detail?existingConfig.events[key].detail:{};const detailKeys=Object.keys(configEventDetail);const existingDetailKeys=Object.keys(existingEventDetail);for(let j=0;j<existingDetailKeys.length;j++){const detailKey=existingDetailKeys[j];if(j>=detailKeys.length||!configEventDetail.hasOwnProperty(detailKey)){explanation=`Event '${key}' has missing entries in the detail payload`;break}else{if(!this._compareType(configEventDetail[detailKey],existingEventDetail[detailKey])){explanation=`Event '${key}' detail attribute '${detailKey}' has a changed type`;break}}}if(!explanation&&config.events[key].bubbles!==existingConfig.events[key].bubbles){explanation=`Event '${key}' has a changed bubbling state`;break}if(!explanation&&config.events[key].cancelable!==existingConfig.events[key].cancelable){explanation=`Event '${key}' has changed cancelable state`;break}}else{explanation=`Event '${key}' has been removed`;break}}return explanation};ruleDef.prototype._detectSlotDiff=function(config,existingConfig){return this._detectTypedSlotDiff('slots',config,existingConfig)};ruleDef.prototype._detectDynamicSlotDiff=function(config,existingConfig){return this._detectTypedSlotDiff('dynamicSlots',config,existingConfig)};ruleDef.prototype._detectTypedSlotDiff=function(slotType,config,existingConfig){let explanation;const configSlots=config[slotType]?Object.keys(config[slotType]):[];const existingSlots=existingConfig[slotType]?Object.keys(existingConfig[slotType]):[];for(let i=0;i<existingSlots.length;i++){const key=existingSlots[i];if(config[slotType].hasOwnProperty(key)){const configSlotData=config[slotType][key].data?config[slotType][key].data:{};const existingSlotData=existingConfig[slotType][key].data?existingConfig[slotType][key].data:{};const dataKeys=Object.keys(configSlotData);const existingDataKeys=Object.keys(existingSlotData);for(let j=0;j<existingDataKeys.length;j++){const dataKey=existingDataKeys[j];if(j>=dataKeys.length||!configSlotData.hasOwnProperty(dataKey)){explanation=`Template slot '${key}' - '${dataKey}' has been removed from data definition`;break}else{if(!this._compareType(configSlotData[dataKey],existingSlotData[dataKey])){explanation=`Template slot '${key}' data attribute '${dataKey}' has a changed type`;break}}}}else{explanation=`Slot '${key}' has been removed`;break}}return explanation};ruleDef.prototype._compareType=function(newTyped,existingTyped){let matches=true;const newType=newTyped&&newTyped.type?newTyped.type:null;const existingType=existingTyped&&existingTyped.type?existingTyped.type:null;if(newType!==existingType){if(newType.includes('|')){const newTypeOptions=newType?newType.split('|'):[];const existingTypeOptions=existingType?existingType.split('|'):[];matches=existingTypeOptions.every(checkType=>newTypeOptions.includes(checkType))}else{matches=false}}return matches};ruleDef.prototype._compareProperties=function(newProps,oldProps,path){let explanation;const configProps=newProps?Object.keys(newProps):[];const existingProps=oldProps?Object.keys(oldProps):[];for(let i=0;i<existingProps.length;i++){const key=existingProps[i];if(newProps.hasOwnProperty(key)){const newProperty=newProps[key];const oldProperty=oldProps[key];if(!this._compareType(newProperty,oldProperty)){explanation=`Property type change for '${path?path:''}${key}'`;break}if(oldProperty.hasOwnProperty('enumValues')){const newOptions=newProperty.hasOwnProperty('enumValues')?newProperty.enumValues:[];if(!oldProperty.enumValues.every(checkOption=>newOptions.includes(checkOption))){explanation=`Enumeration value option removed from property '${path?path:''}${key}'`;break}}else if(newProperty.hasOwnProperty('enumValues')){explanation=`Property '${path?path:''}${key}' is now constrained by an enumeration`;break}if(!path){if(oldProperty.writeback&&!newProperty.writeback){explanation=`Property '${key}' is no longer writeback enabled`;break}if(!oldProperty.required&&newProperty.required){explanation=`Property '${key}' has been made required`;break}const oldROState=oldProperty.hasOwnProperty('readOnly')?oldProperty.readOnly:false;const newROState=newProperty.hasOwnProperty('readOnly')?newProperty.readOnly:false;if(oldROState!==newROState){explanation=`Property '${key}' readOnly state has changed`;break}const oldDefault=oldProperty.hasOwnProperty('value')?JSON.stringify(oldProperty.value):'';const newDefault=newProperty.hasOwnProperty('value')?JSON.stringify(newProperty.value):'';if(oldDefault!==newDefault){explanation=`Property '${key}' default value has changed`;break}}if(newProperty.hasOwnProperty('properties')||oldProperty.hasOwnProperty('properties')){const newSubProps=newProperty.properties?newProperty.properties:{};const oldSubProps=oldProperty.properties?oldProperty.properties:{};const propPath=path?path+key+'.':key+'.';explanation=this._compareProperties(newSubProps,oldSubProps,propPath);if(explanation){break}}}else{explanation=`Property '${path?path:''}${key}' has been removed`;break}}return explanation};module.exports=ruleDef;
|
|
@@ -1 +1,6 @@
|
|
|
1
|
-
const Utils=require('../jetwc-lib/component-audit-utils');const NetUtils=require('../../lib/NetUtils');const EXCHANGEROOT='https://exchange.oraclecorp.com/api/0.2.0/components/';const ruleDef=function(){};ruleDef.prototype.getName=function(){return'jetwco-component-api-changes'};ruleDef.prototype.getShortDescription=function(){return'Verify that any API changes are compatible with the version number change'};ruleDef.prototype.getDescription=function(){return'This audit compares the metadata of the previous version of a component in the Exchange Catalog and verifies that any API changes are matched with an appropriate version number change according to semver rules'};ruleDef.prototype.register=function(context){return{compjson:this._doAudit}};ruleDef.prototype._doAudit=function(context,arg1){if(context.suppData.obj){const componentDef=context.suppData.obj;const fullName=componentDef.pack?`${componentDef.pack}-${componentDef.name}`:componentDef.name;const semver=context.utils.semVerUtils;let newVersion,latestMatchVersion;try{const netUtils=new NetUtils;const existingVersionsResp=netUtils.loadUrl(`${EXCHANGEROOT}${fullName}/versions`);if(existingVersionsResp.statusCode=200&&existingVersionsResp.body){const existingVersions=JSON.parse(existingVersionsResp.body);if(existingVersions.items&&existingVersions.items.length>0){newVersion=componentDef.version;let minorVersionUpdated=false;latestMatchVersion=this._findMostAppropriateComparitor(existingVersions,newVersion,semver);if(latestMatchVersion){if(this._isAPICheckNeeded(semver,newVersion,latestMatchVersion)){minorVersionUpdated=this._isEffectiveMinor(semver,newVersion,latestMatchVersion);const uploadedResp=netUtils.loadUrl(`${EXCHANGEROOT}${fullName}/versions/${latestMatchVersion}`);if(uploadedResp.statusCode=200&&uploadedResp.body){const existingDef=JSON.parse(uploadedResp.body).component;try{this._conductCheck(this._detectJetVersionDiff,semver,componentDef,existingDef,minorVersionUpdated);this._conductCheck(this._detectDependencyDiff,semver,componentDef,existingDef,minorVersionUpdated);this._conductCheck(this._detectMethodDiff,componentDef,existingDef,minorVersionUpdated);this._conductCheck(this._detectPropertyDiff,componentDef,existingDef,minorVersionUpdated);this._conductCheck(this._detectEventDiff,componentDef,existingDef,minorVersionUpdated);this._conductCheck(this._detectSlotDiff,componentDef,existingDef,minorVersionUpdated);this._conductCheck(this._detectDynamicSlotDiff,componentDef,existingDef,minorVersionUpdated)}catch(auditDetail){const issue=new context.Issue(`API change for ${fullName}@${newVersion} (compared with @${latestMatchVersion}) is not matched by appropriate version number update. Indication: ${auditDetail}`,'0011');context.reporter.addIssue(issue,context,'blocker')}}}else{}}}}}catch(e){console.log(JSON.stringify(e))};}};ruleDef.prototype._findMostAppropriateComparitor=function(existingVersions,newVersion,semver){const versions=existingVersions.items.reverse();let closestMatch,firstMatch,closestReleaseMatch;for(let i=0;i<versions.length;i++){if(semver.gte(newVersion,versions[i])){closestMatch=versions[i];if(!firstMatch){firstMatch=closestMatch}if(!this._isPreRelease(semver,closestMatch)||semver.major(closestMatch)===0){closestReleaseMatch=closestMatch;break}else{continue}}}return closestReleaseMatch?closestReleaseMatch:firstMatch};ruleDef.prototype._isPreRelease=function(semver,version){return Array.isArray(semver.prerelease(version))};ruleDef.prototype._isAPICheckNeeded=function(semver,newVersion,existingVersion){let doCheck=true;if(semver.major(newVersion)>semver.major(existingVersion)||semver.major(newVersion)===0&&semver.minor(newVersion)>semver.minor(existingVersion)){doCheck=false}return doCheck};ruleDef.prototype._isEffectiveMinor=function(semver,newVersion,existingVersion){let classAsMinor=false;if(semver.minor(newVersion)>semver.minor(existingVersion)||semver.major(newVersion)===0&&semver.patch(newVersion)>semver.patch(existingVersion)){classAsMinor=true}return classAsMinor};ruleDef.prototype._conductCheck=function(checkCallback,semver,config,existingConfig,claimedMinorDiff){const result=checkCallback.call(this,semver,config,existingConfig,claimedMinorDiff);if(result){throw result}};ruleDef.prototype._detectJetVersionDiff=function(semver,config,existingConfig,claimedMinorDiff){let explanation;const componentJetVersion=config.jetVersion?config.jetVersion:'0.0.0';const existingJetVersion=existingConfig.jetVersion?existingConfig.jetVersion:'0.0.0';if(componentJetVersion!==existingJetVersion){if(existingJetVersion==='0.0.0'||componentJetVersion==='0.0.0'){explanation='JET version range has been added or removed'}else{const minVersion=semver.minVersion(componentJetVersion);const minExistingVersion=semver.minVersion(existingJetVersion);if(semver.major(minVersion)>semver.major(minExistingVersion)){explanation='minimum major JET version required has increased'}else if(!claimedMinorDiff){if(semver.minor(minVersion)>semver.minor(minExistingVersion)){explanation='minimum minor JET version required has increased'}}}}return explanation};ruleDef.prototype._detectDependencyDiff=function(semver,config,existingConfig,claimedMinorDiff){let explanation;const configDeps=config.dependencies?Object.keys(config.dependencies):[];const existingDeps=existingConfig.dependencies?Object.keys(existingConfig.dependencies):[];if(configDeps.length>existingDeps.length){explanation='more dependencies are declared'}else{if(configDeps.length>0){for(let i=0;i<existingDeps.length;i++){const key=existingDeps[i];if(config.dependencies.hasOwnProperty(key)){const newDepVersion=semver.minVersion(config.dependencies[key]);const existingDepVersion=semver.minVersion(existingConfig.dependencies[key]);if(semver.major(newDepVersion)!==semver.major(existingDepVersion)){explanation='different major version of dependency '+key;break}if(!claimedMinorDiff){if(semver.minor(newDepVersion)!==semver.minor(existingDepVersion)){explanation='different minor version of dependency '+key;break}}}else{if(!claimedMinorDiff){explanation=`dependency ${key} has been removed`}break}}}}return explanation};ruleDef.prototype._detectMethodDiff=function(config,existingConfig,claimedMinorDiff){let explanation;const configMethods=config.methods?Object.keys(config.methods):[];const existingMethods=existingConfig.methods?Object.keys(existingConfig.methods):[];if(configMethods.length>=existingMethods.length){if(claimedMinorDiff){if(!existingMethods.every(checkName=>configMethods.includes(checkName))){explanation='existing method removed'}}else if(configMethods.length!==existingMethods.length){explanation='different number of methods declared'}}else{if(configMethods.length===0&&existingMethods.length>0){explanation='existing method(s) removed'}}if(!explanation){for(let i=0;i<existingMethods.length;i++){const key=existingMethods[i];if(config.methods.hasOwnProperty(key)){const configMethodParams=config.methods[key].params?config.methods[key].params:[];const existingMethodParams=existingConfig.methods[key].params?existingConfig.methods[key].params:[];for(let j=0;j<existingMethodParams.length;j++){if(j>=configMethodParams.length){explanation=`existing method '${key}' has fewer parameters`;break}else{if(!this._compareType(configMethodParams[j],existingMethodParams[j],claimedMinorDiff)){explanation=`method '${key}' parameter number:${j+1} has a changed type`;break}}}if(!explanation&&configMethodParams.length>existingMethodParams.length&&!claimedMinorDiff){explanation=`existing method '${key}' has additional parameters`;break}}else{explanation=`existing method '${key}' has been removed`;break}}}return explanation};ruleDef.prototype._detectPropertyDiff=function(config,existingConfig,claimedMinorDiff){let explanation;const configProps=config.properties?Object.keys(config.properties):[];const existingProps=existingConfig.properties?Object.keys(existingConfig.properties):[];if(configProps.length>=existingProps.length){if(claimedMinorDiff){if(!existingProps.every(checkName=>configProps.includes(checkName))){explanation='existing property removed'}}else if(configProps.length!==existingProps.length){explanation='different number of properties declared'}}else{if(configProps.length===0&&existingProps.length>0){explanation='existing properties removed'}}if(!explanation){explanation=this._compareProperties(config.properties,existingConfig.properties,claimedMinorDiff)}return explanation};ruleDef.prototype._detectEventDiff=function(config,existingConfig,claimedMinorDiff){let explanation;const configEvents=config.events?Object.keys(config.events):[];const existingEvents=existingConfig.events?Object.keys(existingConfig.events):[];if(configEvents.length>=existingEvents.length){if(claimedMinorDiff){if(!existingEvents.every(checkName=>configEvents.includes(checkName))){explanation='existing event removed'}}else if(configEvents.length!==existingEvents.length){explanation='different number of events declared'}}else{if(configEvents.length===0&&existingEvents.length>0){explanation='existing event(s) removed'}}if(!explanation){for(let i=0;i<existingEvents.length;i++){const key=existingEvents[i];if(config.events.hasOwnProperty(key)){const configEventDetail=config.events[key].detail?config.events[key].detail:{};const existingEventDetail=existingConfig.events[key].detail?existingConfig.events[key].detail:{};const detailKeys=Object.keys(configEventDetail);const existingDetailKeys=Object.keys(existingEventDetail);for(let j=0;j<existingDetailKeys.length;j++){const detailKey=existingDetailKeys[j];if(j>=detailKeys.length||!configEventDetail.hasOwnProperty(detailKey)){explanation=`existing event '${key}' has missing entries in the detail payload`;break}else{if(!this._compareType(configEventDetail[detailKey],existingEventDetail[detailKey],claimedMinorDiff)){explanation=`event '${key}' detail attribute '${detailKey}' has a changed type`;break}}}if(!explanation&&detailKeys.length>existingDetailKeys.length&&!claimedMinorDiff){explanation=`existing event '${key}' has additional entries in the detail payload`;break}if(!explanation&&config.events[key].bubbles!==existingConfig.events[key].bubbles){explanation=`existing event '${key}' has changed bubbling state`;break}if(!explanation&&config.events[key].cancelable!==existingConfig.events[key].cancelable){explanation=`existing event '${key}' has changed cancelable state`;break}}else{explanation=`existing event '${key}' has been removed`;break}}}return explanation};ruleDef.prototype._detectSlotDiff=function(config,existingConfig,claimedMinorDiff){return this._detectTypedSlotDiff('slots',config,existingConfig,claimedMinorDiff)};ruleDef.prototype._detectDynamicSlotDiff=function(config,existingConfig,claimedMinorDiff){return this._detectTypedSlotDiff('dynamicSlots',config,existingConfig,claimedMinorDiff)};ruleDef.prototype._detectTypedSlotDiff=function(slotType,config,existingConfig,claimedMinorDiff){let explanation;const configSlots=config[slotType]?Object.keys(config[slotType]):[];const existingSlots=existingConfig[slotType]?Object.keys(existingConfig[slotType]):[];if(configSlots.length>=existingSlots.length){if(claimedMinorDiff){if(!existingSlots.every(checkName=>configSlots.includes(checkName))){explanation='existing slot removed'}}else if(configSlots.length!==existingSlots.length){explanation='different number of slots declared'}}else{if(configSlots.length===0&&existingSlots.length>0){explanation='existing slot(s) removed'}}if(!explanation){for(let i=0;i<existingSlots.length;i++){const key=existingSlots[i];if(config[slotType].hasOwnProperty(key)){const configSlotData=config[slotType][key].data?config[slotType][key].data:{};const existingSlotData=existingConfig[slotType][key].data?existingConfig[slotType][key].data:{};const dataKeys=Object.keys(configSlotData);const existingDataKeys=Object.keys(existingSlotData);for(let j=0;j<existingDataKeys.length;j++){const dataKey=existingDataKeys[j];if(j>=dataKeys.length||!configSlotData.hasOwnProperty(dataKey)){explanation=`existing slot '${key}' has missing entries in the data payload`;break}else{if(!this._compareType(configSlotData[dataKey],existingSlotData[dataKey],claimedMinorDiff)){explanation=`slot '${key}' data attribute '${dataKey}' has a changed type`;break}}}if(!explanation&&dataKeys.length>existingDataKeys.length&&!claimedMinorDiff){explanation=`existing slot '${key}' has additional entries in the data payload`;break}}else{explanation=`existing slot '${key}' has been removed`;break}}}return explanation};ruleDef.prototype._compareType=function(newTyped,existingTyped,claimedMinorDiff){let matches=true;const newType=newTyped&&newTyped.type?newTyped.type:null;const existingType=existingTyped&&existingTyped.type?existingTyped.type:null;if(newType!==existingType){if(claimedMinorDiff){const newTypeOptions=newType?newType.split('|'):[];const existingTypeOptions=existingType?existingType.split('|'):[];matches=existingTypeOptions.every(checkType=>newTypeOptions.includes(checkType))}else{matches=false}}return matches};ruleDef.prototype._compareProperties=function(newProps,oldProps,claimedMinorDiff,path){let explanation;const configProps=newProps?Object.keys(newProps):[];const existingProps=oldProps?Object.keys(oldProps):[];for(let i=0;i<existingProps.length;i++){const key=existingProps[i];if(newProps.hasOwnProperty(key)){const newProperty=newProps[key];const oldProperty=oldProps[key];if(!this._compareType(newProperty,oldProperty,claimedMinorDiff)){explanation=`type change for property ${path?path:''}${key}`;break}if(!path){if(oldProperty.writeback&&!newProperty.writeback){explanation=`property ${key} is no longer writeback enabled`;break}if(!oldProperty.required&&newProperty.required){explanation=`property ${key} has been made required`;break}}if(newProperty.hasOwnProperty('properties')||oldProperty.hasOwnProperty('properties')){const newSubProps=newProperty.properties?newProperty.properties:{};const oldSubProps=oldProperty.properties?oldProperty.properties:{};const propPath=path?path+key+'.':key+'.';explanation=this._compareProperties(newSubProps,oldSubProps,claimedMinorDiff,propPath);if(explanation){break}}}else{explanation=`property ${path?path:''}${key} has been removed`;break}}if(!explanation){if(!claimedMinorDiff&&configProps.length>existingProps.length){explanation=`property added ${path?'as sub-property of '+path:''}`}}return explanation};module.exports=ruleDef;
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2018, 2021, Oracle and/or its affiliates.
|
|
3
|
+
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
|
+
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
|
+
*/
|
|
6
|
+
const Utils=require('../jetwc-lib/component-audit-utils');const NetUtils=require('../../lib/NetUtils');const EXCHANGEROOT='https://exchange.oraclecorp.com/api/0.2.0/components/';const ruleDef=function(){};ruleDef.prototype.getName=function(){return'jetwco-component-api-changes'};ruleDef.prototype.getShortDescription=function(){return'Verify that any API changes are compatible with the version number change'};ruleDef.prototype.getDescription=function(){return'This audit compares the metadata of the previous version of a component in the Exchange Catalog and verifies that any API changes are matched with an appropriate version number change according to semver rules'};ruleDef.prototype.register=function(context){return{startupRP:this._prepareCache,closedownRP:this._dealWithCache,compjson:this._doAudit}};ruleDef.prototype._prepareCache=function(context){Utils.ensureLocalCache(context)};ruleDef.prototype._dealWithCache=function(context){const shouldClearCache=context.rulePack.getRuleOption('clearCache','jetwco-component-api-changes');if(shouldClearCache){Utils.removeLocalCache(context)}};ruleDef.prototype._doAudit=function(context,arg1){if(context.suppData.obj){const componentDef=context.suppData.obj;const fullName=componentDef.pack?`${componentDef.pack}-${componentDef.name}`:componentDef.name;const semver=context.utils.semVerUtils;let newVersion,latestMatchVersion;try{const netUtils=new NetUtils;const existingVersionsResp=netUtils.loadUrl(`${EXCHANGEROOT}${fullName}/versions`);if(existingVersionsResp.statusCode=200&&existingVersionsResp.body){const existingVersions=JSON.parse(existingVersionsResp.body);if(existingVersions.items&&existingVersions.items.length>0){newVersion=componentDef.version;let minorVersionUpdated=false;latestMatchVersion=this._findMostAppropriateComparitor(existingVersions,newVersion,semver);if(latestMatchVersion){if(this._isAPICheckNeeded(semver,newVersion,latestMatchVersion)){minorVersionUpdated=this._isEffectiveMinor(semver,newVersion,latestMatchVersion);let existingDef;if(Utils.existsInComponentCache(context,fullName,latestMatchVersion)){existingDef=Utils.readFromComponentCache(context,fullName,latestMatchVersion)}else{const uploadedResp=netUtils.loadUrl(`${EXCHANGEROOT}${fullName}/versions/${latestMatchVersion}`);if(uploadedResp.statusCode=200&&uploadedResp.body){existingDef=JSON.parse(uploadedResp.body).component;Utils.writeToComponentCache(context,fullName,latestMatchVersion,existingDef)}}if(existingDef){try{this._conductCheck(this._detectJetVersionDiff,semver,componentDef,existingDef,minorVersionUpdated);this._conductCheck(this._detectDependencyDiff,semver,componentDef,existingDef,minorVersionUpdated);this._conductCheck(this._detectMethodDiff,componentDef,existingDef,minorVersionUpdated);this._conductCheck(this._detectPropertyDiff,componentDef,existingDef,minorVersionUpdated);this._conductCheck(this._detectEventDiff,componentDef,existingDef,minorVersionUpdated);this._conductCheck(this._detectSlotDiff,componentDef,existingDef,minorVersionUpdated);this._conductCheck(this._detectDynamicSlotDiff,componentDef,existingDef,minorVersionUpdated)}catch(auditDetail){const issue=new context.Issue(`API change for ${fullName}@${newVersion} (compared with @${latestMatchVersion}) is not matched by appropriate version number update. Indication: ${auditDetail}`);context.reporter.addIssue(issue,context,'blocker')}}else{console.error(`Unable to obtain metadata for ${fullName}@${latestMatchVersion}`)}}else{}}}}}catch(e){console.error(JSON.stringify(e))};}};ruleDef.prototype._findMostAppropriateComparitor=function(existingVersions,newVersion,semver){const versions=existingVersions.items.reverse();let closestMatch,firstMatch,closestReleaseMatch;for(let i=0;i<versions.length;i++){if(semver.gte(newVersion,versions[i])){closestMatch=versions[i];if(!firstMatch){firstMatch=closestMatch}if(!this._isPreRelease(semver,closestMatch)||semver.major(closestMatch)===0){closestReleaseMatch=closestMatch;break}else{continue}}}return closestReleaseMatch?closestReleaseMatch:firstMatch};ruleDef.prototype._isPreRelease=function(semver,version){return Array.isArray(semver.prerelease(version))};ruleDef.prototype._isAPICheckNeeded=function(semver,newVersion,existingVersion){let doCheck=true;if(semver.major(newVersion)>semver.major(existingVersion)||semver.major(newVersion)===0&&semver.minor(newVersion)>semver.minor(existingVersion)){doCheck=false}return doCheck};ruleDef.prototype._isEffectiveMinor=function(semver,newVersion,existingVersion){let classAsMinor=false;if(semver.minor(newVersion)>semver.minor(existingVersion)||semver.major(newVersion)===0&&semver.patch(newVersion)>semver.patch(existingVersion)){classAsMinor=true}return classAsMinor};ruleDef.prototype._conductCheck=function(checkCallback,semver,config,existingConfig,claimedMinorDiff){const result=checkCallback.call(this,semver,config,existingConfig,claimedMinorDiff);if(result){throw result}};ruleDef.prototype._detectJetVersionDiff=function(semver,config,existingConfig,claimedMinorDiff){let explanation;const componentJetVersion=config.jetVersion?config.jetVersion:'0.0.0';const existingJetVersion=existingConfig.jetVersion?existingConfig.jetVersion:'0.0.0';if(componentJetVersion!==existingJetVersion){if(existingJetVersion==='0.0.0'||componentJetVersion==='0.0.0'){explanation='JET version range has been added or removed'}else{const minVersion=semver.minVersion(componentJetVersion);const minExistingVersion=semver.minVersion(existingJetVersion);if(semver.major(minVersion)>semver.major(minExistingVersion)){explanation='minimum major JET version required has increased'}else if(!claimedMinorDiff){if(semver.minor(minVersion)>semver.minor(minExistingVersion)){explanation='minimum minor JET version required has increased'}}}}return explanation};ruleDef.prototype._detectDependencyDiff=function(semver,config,existingConfig,claimedMinorDiff){let explanation;const configDeps=config.dependencies?Object.keys(config.dependencies):[];const existingDeps=existingConfig.dependencies?Object.keys(existingConfig.dependencies):[];if(configDeps.length>existingDeps.length){explanation='more dependencies are declared'}else{if(configDeps.length>0){for(let i=0;i<existingDeps.length;i++){const key=existingDeps[i];if(config.dependencies.hasOwnProperty(key)){const newDepVersion=semver.minVersion(config.dependencies[key]);const existingDepVersion=semver.minVersion(existingConfig.dependencies[key]);if(semver.major(newDepVersion)!==semver.major(existingDepVersion)){explanation='different major version of dependency '+key;break}if(!claimedMinorDiff){if(semver.minor(newDepVersion)!==semver.minor(existingDepVersion)){explanation='different minor version of dependency '+key;break}}}else{if(!claimedMinorDiff){explanation=`dependency ${key} has been removed`}break}}}}return explanation};ruleDef.prototype._detectMethodDiff=function(config,existingConfig,claimedMinorDiff){let explanation;const configMethods=config.methods?Object.keys(config.methods):[];const existingMethods=existingConfig.methods?Object.keys(existingConfig.methods):[];if(configMethods.length>=existingMethods.length){if(claimedMinorDiff){if(!existingMethods.every(checkName=>configMethods.includes(checkName))){explanation='existing method removed'}}else if(configMethods.length!==existingMethods.length){explanation='different number of methods declared'}}else{if(configMethods.length===0&&existingMethods.length>0){explanation='existing method(s) removed'}}if(!explanation){for(let i=0;i<existingMethods.length;i++){const key=existingMethods[i];if(config.methods.hasOwnProperty(key)){const configMethodParams=config.methods[key].params?config.methods[key].params:[];const existingMethodParams=existingConfig.methods[key].params?existingConfig.methods[key].params:[];for(let j=0;j<existingMethodParams.length;j++){if(j>=configMethodParams.length){explanation=`existing method '${key}' has fewer parameters`;break}else{if(!this._compareType(configMethodParams[j],existingMethodParams[j],claimedMinorDiff)){explanation=`method '${key}' parameter number:${j+1} has a changed type`;break}}}if(!explanation&&configMethodParams.length>existingMethodParams.length&&!claimedMinorDiff){explanation=`existing method '${key}' has additional parameters`;break}}else{explanation=`existing method '${key}' has been removed`;break}}}return explanation};ruleDef.prototype._detectPropertyDiff=function(config,existingConfig,claimedMinorDiff){let explanation;const configProps=config.properties?Object.keys(config.properties):[];const existingProps=existingConfig.properties?Object.keys(existingConfig.properties):[];if(configProps.length>=existingProps.length){if(claimedMinorDiff){if(!existingProps.every(checkName=>configProps.includes(checkName))){explanation='existing property removed'}}else if(configProps.length!==existingProps.length){explanation='different number of properties declared'}}else{if(configProps.length===0&&existingProps.length>0){explanation='existing properties removed'}}if(!explanation){explanation=this._compareProperties(config.properties,existingConfig.properties,claimedMinorDiff)}return explanation};ruleDef.prototype._detectEventDiff=function(config,existingConfig,claimedMinorDiff){let explanation;const configEvents=config.events?Object.keys(config.events):[];const existingEvents=existingConfig.events?Object.keys(existingConfig.events):[];if(configEvents.length>=existingEvents.length){if(claimedMinorDiff){if(!existingEvents.every(checkName=>configEvents.includes(checkName))){explanation='existing event removed'}}else if(configEvents.length!==existingEvents.length){explanation='different number of events declared'}}else{if(configEvents.length===0&&existingEvents.length>0){explanation='existing event(s) removed'}}if(!explanation){for(let i=0;i<existingEvents.length;i++){const key=existingEvents[i];if(config.events.hasOwnProperty(key)){const configEventDetail=config.events[key].detail?config.events[key].detail:{};const existingEventDetail=existingConfig.events[key].detail?existingConfig.events[key].detail:{};const detailKeys=Object.keys(configEventDetail);const existingDetailKeys=Object.keys(existingEventDetail);for(let j=0;j<existingDetailKeys.length;j++){const detailKey=existingDetailKeys[j];if(j>=detailKeys.length||!configEventDetail.hasOwnProperty(detailKey)){explanation=`existing event '${key}' has missing entries in the detail payload`;break}else{if(!this._compareType(configEventDetail[detailKey],existingEventDetail[detailKey],claimedMinorDiff)){explanation=`event '${key}' detail attribute '${detailKey}' has a changed type`;break}}}if(!explanation&&detailKeys.length>existingDetailKeys.length&&!claimedMinorDiff){explanation=`existing event '${key}' has additional entries in the detail payload`;break}if(!explanation&&config.events[key].bubbles!==existingConfig.events[key].bubbles){explanation=`existing event '${key}' has changed bubbling state`;break}if(!explanation&&config.events[key].cancelable!==existingConfig.events[key].cancelable){explanation=`existing event '${key}' has changed cancelable state`;break}}else{explanation=`existing event '${key}' has been removed`;break}}}return explanation};ruleDef.prototype._detectSlotDiff=function(config,existingConfig,claimedMinorDiff){return this._detectTypedSlotDiff('slots',config,existingConfig,claimedMinorDiff)};ruleDef.prototype._detectDynamicSlotDiff=function(config,existingConfig,claimedMinorDiff){return this._detectTypedSlotDiff('dynamicSlots',config,existingConfig,claimedMinorDiff)};ruleDef.prototype._detectTypedSlotDiff=function(slotType,config,existingConfig,claimedMinorDiff){let explanation;const configSlots=config[slotType]?Object.keys(config[slotType]):[];const existingSlots=existingConfig[slotType]?Object.keys(existingConfig[slotType]):[];if(configSlots.length>=existingSlots.length){if(claimedMinorDiff){if(!existingSlots.every(checkName=>configSlots.includes(checkName))){explanation='existing slot removed'}}else if(configSlots.length!==existingSlots.length){explanation='different number of slots declared'}}else{if(configSlots.length===0&&existingSlots.length>0){explanation='existing slot(s) removed'}}if(!explanation){for(let i=0;i<existingSlots.length;i++){const key=existingSlots[i];if(config[slotType].hasOwnProperty(key)){const configSlotData=config[slotType][key].data?config[slotType][key].data:{};const existingSlotData=existingConfig[slotType][key].data?existingConfig[slotType][key].data:{};const dataKeys=Object.keys(configSlotData);const existingDataKeys=Object.keys(existingSlotData);for(let j=0;j<existingDataKeys.length;j++){const dataKey=existingDataKeys[j];if(j>=dataKeys.length||!configSlotData.hasOwnProperty(dataKey)){explanation=`existing slot '${key}' has missing entries in the data payload`;break}else{if(!this._compareType(configSlotData[dataKey],existingSlotData[dataKey],claimedMinorDiff)){explanation=`slot '${key}' data attribute '${dataKey}' has a changed type`;break}}}if(!explanation&&dataKeys.length>existingDataKeys.length&&!claimedMinorDiff){explanation=`existing slot '${key}' has additional entries in the data payload`;break}}else{explanation=`existing slot '${key}' has been removed`;break}}}return explanation};ruleDef.prototype._compareType=function(newTyped,existingTyped,claimedMinorDiff){let matches=true;const newType=newTyped&&newTyped.type?newTyped.type:null;const existingType=existingTyped&&existingTyped.type?existingTyped.type:null;if(newType!==existingType){if(claimedMinorDiff){const newTypeOptions=newType?newType.split('|'):[];const existingTypeOptions=existingType?existingType.split('|'):[];matches=existingTypeOptions.every(checkType=>newTypeOptions.includes(checkType))}else{matches=false}}return matches};ruleDef.prototype._compareProperties=function(newProps,oldProps,claimedMinorDiff,path){let explanation;const configProps=newProps?Object.keys(newProps):[];const existingProps=oldProps?Object.keys(oldProps):[];for(let i=0;i<existingProps.length;i++){const key=existingProps[i];if(newProps.hasOwnProperty(key)){const newProperty=newProps[key];const oldProperty=oldProps[key];if(!this._compareType(newProperty,oldProperty,claimedMinorDiff)){explanation=`type change for property ${path?path:''}${key}`;break}if(oldProperty.hasOwnProperty('enumValues')){const newOptions=newProperty.hasOwnProperty('enumValues')?newProperty.enumValues:[];if(!oldProperty.enumValues.every(checkOption=>newOptions.includes(checkOption))){explanation=`Enumeration value option removed from property '${path?path:''}${key}'`;break}}else if(newProperty.hasOwnProperty('enumValues')){explanation=`Property '${path?path:''}${key}' is now constrained by an enumeration`;break}if(!path){if(oldProperty.writeback&&!newProperty.writeback){explanation=`property ${key} is no longer writeback enabled`;break}if(!oldProperty.required&&newProperty.required){explanation=`property ${key} has been made required`;break}if(!oldProperty.required&&newProperty.required){explanation=`Property '${key}' has been made required`;break}const oldROState=oldProperty.hasOwnProperty('readOnly')?oldProperty.readOnly:false;const newROState=newProperty.hasOwnProperty('readOnly')?newProperty.readOnly:false;if(oldROState!==newROState){explanation=`Property '${key}' readOnly state has changed`;break}}if(newProperty.hasOwnProperty('properties')||oldProperty.hasOwnProperty('properties')){const newSubProps=newProperty.properties?newProperty.properties:{};const oldSubProps=oldProperty.properties?oldProperty.properties:{};const propPath=path?path+key+'.':key+'.';explanation=this._compareProperties(newSubProps,oldSubProps,claimedMinorDiff,propPath);if(explanation){break}}}else{explanation=`property ${path?path:''}${key} has been removed`;break}}if(!explanation){if(!claimedMinorDiff&&configProps.length>existingProps.length){explanation=`property added ${path?'as sub-property of '+path:''}`}}return explanation};module.exports=ruleDef;
|
|
@@ -1 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2018, 2021, Oracle and/or its affiliates.
|
|
3
|
+
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
|
+
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
|
+
*/
|
|
6
|
+
const Utils=require('../jetwc-lib/component-audit-utils');const ruleDef=function(){};ruleDef.prototype.getName=function(){return'jetwco-component-cdn'};ruleDef.prototype.getShortDescription=function(){return'Checks to see if relevant components have a CDN location defined'};ruleDef.prototype.getDescription=function(){return'This rule flags any reference or pack components that do not have a CDN path defined'};ruleDef.prototype.register=function(context){return{compjson:this._doAudit}};ruleDef.prototype._doAudit=function(context){if(context.suppData.obj){let issue;const meta=context.suppData.obj;const componentType=Utils.getComponentType(meta);const componentName=meta.name;switch(componentType){case'pack':case'reference':if(!meta.paths||!meta.paths.cdn||!meta.paths.cdn.hasOwnProperty('min')&&!meta.paths.cdn.hasOwnProperty('debug')){issue=new context.Issue(`${componentType} component ${componentName} does not have a CDN location defined`);context.reporter.addIssue(issue,context,'major')}break;default:break;}}};module.exports=ruleDef;
|
|
@@ -1 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2018, 2021, Oracle and/or its affiliates.
|
|
3
|
+
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
|
+
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
|
+
*/
|
|
6
|
+
const Utils=require('../jetwc-lib/component-audit-utils');const NetUtils=require('../../lib/NetUtils');const EXCHANGEROOT='https://exchange.oraclecorp.com/api/0.2.0/components/';const ruleDef=function(){};ruleDef.prototype.getName=function(){return'jetwco-exchange-version-check'};ruleDef.prototype.getShortDescription=function(){return'Verify version is not already in Exchange'};ruleDef.prototype.getDescription=function(){return'This audit checks that the version specified for this component does not already exist in Exchange. This may not actually be an error, hence this informational only.'};ruleDef.prototype.register=function(context){return{compjson:this._doAudit}};ruleDef.prototype._doAudit=function(context,arg1){if(context.suppData.obj){const componentDef=context.suppData.obj;const fullName=componentDef.pack?`${componentDef.pack}-${componentDef.name}`:componentDef.name;const semver=context.utils.semVerUtils;try{const netUtils=new NetUtils;const existingVersionsResp=netUtils.loadUrl(`${EXCHANGEROOT}${fullName}/versions`);if(existingVersionsResp.statusCode=200&&existingVersionsResp.body){const existingVersions=JSON.parse(existingVersionsResp.body);if(existingVersions.items&&existingVersions.items.length>0){const newVersion=componentDef.version;let latestMatchVersion,nextProjectedVersion;const versions=existingVersions.items.reverse();for(let i=0;i<versions.length;i++){if(semver.gte(newVersion,versions[i])){latestMatchVersion=versions[i];if(i>0){nextProjectedVersion=versions[i-1]}break}}if(latestMatchVersion){if(latestMatchVersion===newVersion){const sameissue=new context.Issue(`The version number defined for ${fullName} (${newVersion}) already exists in Exchange`);sameissue.setMsgKey('jetwco-exchange-version-check_1');context.reporter.addIssue(sameissue,context,'info')}else if(nextProjectedVersion){const futureissue=new context.Issue(`The version number defined for ${fullName} (${newVersion}) is lower than existing versions in Exchange`);futureissue.setMsgKey('jetwco-exchange-version-check_2');context.reporter.addIssue(futureissue,context,'info')}}}}}catch(e){console.log(JSON.stringify(e))};}};module.exports=ruleDef;
|
|
@@ -1 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2018, 2021, Oracle and/or its affiliates.
|
|
3
|
+
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
|
+
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
|
+
*/
|
|
6
|
+
const path=require('path');const ruleDef=function(){};ruleDef.prototype.getName=function(){return'jetwco-license-info'};ruleDef.prototype.getShortDescription=function(){return'Validate Licence Information'};ruleDef.prototype.getDescription=function(){return'This rule is checks that a license file (LICENSE.txt) and third party license (THIRD_PARTY_LICENSE.txt) file is present if required'};ruleDef.prototype.register=function(context){return{compjson:this._doAudit}};ruleDef.prototype._doAudit=function(context){const componentMetadata=context.suppData.obj;const rulePackState=context.rulePack.getExtension();if(componentMetadata){let issue;let licenseFound=false;let licenseCandidate='LICENSE.txt';const compRootFiles=context.utils.fsUtils.readDir(path.dirname(context.filepath));for(let i=0;i<compRootFiles.length;i++){const rootEntry=compRootFiles[i];if(rootEntry.isFile&&rootEntry.name===licenseCandidate){licenseFound=true;break}}if(!licenseFound){issue=new context.Issue(`Component is missing license information file in root, 'LICENSE.txt' is expected (case sensitive)`);issue.setMsgKey(context.ruleName+'_1');context.reporter.addIssue(issue,context,'blocker')}let thirdPartyScan=false;if(componentMetadata.type&&componentMetadata.type==='reference'){thirdPartyScan=true}else{if(componentMetadata.dependencies){if(rulePackState.allReferenceComponents){Object.keys(componentMetadata.dependencies).forEach(dependency=>{if(rulePackState.allReferenceComponents.has(dependency)){thirdPartyScan=true}})}else{console.warn('JETWC: Unable to scan for reference component dependecies - JETWC-BOOTSTRAP was not run')}}}if(thirdPartyScan){licenseFound=false;licenseCandidate='THIRD_PARTY_LICENSE.txt';for(let i=0;i<compRootFiles.length;i++){const rootEntry=compRootFiles[i];if(rootEntry.isFile&&rootEntry.name===licenseCandidate){licenseFound=true;break}}if(!licenseFound){issue=new context.Issue(`Component with third party dependencies is missing 3rd party license information file in root, 'THIRD_PARTY_LICENSE.txt' is expected (case sensitive)`);issue.setMsgKey(context.ruleName+'_2');context.reporter.addIssue(issue,context,'blocker')}}}};module.exports=ruleDef;
|
|
@@ -1 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2018, 2021, Oracle and/or its affiliates.
|
|
3
|
+
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
|
+
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
|
+
*/
|
|
6
|
+
const Utils=require('../jetwc-lib/component-audit-utils');const ruleDef=function(){};ruleDef.prototype.getName=function(){return'jetwco-prerelease-cdn'};ruleDef.prototype.getShortDescription=function(){return'Validates use of the production CDN'};ruleDef.prototype.getDescription=function(){return'This rule checks any CDN definitions to ensure that they point to assets on the production Oracle CDN, not the staging site or other sites'};ruleDef.prototype.register=function(context){return{compjson:this._doAudit}};ruleDef.prototype._doAudit=function(context){const productionCDN=context.rulePack.getRuleOptions().cdnRoot.toLowerCase();if(context.suppData.obj){let issue;const meta=context.suppData.obj;const componentType=Utils.getComponentType(meta);const componentName=meta.name;if(meta.paths&&meta.paths.cdn){if(meta.paths.cdn.min&&!meta.paths.cdn.min.toLowerCase().startsWith(productionCDN)||meta.paths.cdn.debug&&!meta.paths.cdn.debug.toLowerCase().startsWith(productionCDN)){issue=new context.Issue(`${componentType} component '${componentName}' does not use the correct CDN (${productionCDN})`);context.reporter.addIssue(issue,context,'blocker')}}}};module.exports=ruleDef;
|
|
@@ -1 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2018, 2021, Oracle and/or its affiliates.
|
|
3
|
+
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
|
+
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
|
+
*/
|
|
6
|
+
const Utils=require('../jetwc-lib/component-audit-utils');const ruleDef=function(){};ruleDef.prototype.getName=function(){return'jetwco-thirdparty-ba'};ruleDef.prototype.getShortDescription=function(){return'Validate Business Approvals'};ruleDef.prototype.getDescription=function(){return'This rule is applied to reference component and any components that depend on reference components to ensure that the PLS Business Approval number is recorded'};ruleDef.prototype.register=function(context){return{compjson:this._doAudit}};ruleDef.prototype._doAudit=function(context){const componentMetadata=context.suppData.obj;const referenceComponents=context.rulePack.getExtension().allReferenceComponents;if(componentMetadata){let issue;const componentType=Utils.getComponentType(componentMetadata);if(componentMetadata.dependencies){Object.keys(componentMetadata.dependencies).forEach(dependency=>{if(referenceComponents.has(dependency)){const referencedLibs=referenceComponents.get(dependency);if(referencedLibs&&Object.keys(referencedLibs).length>0){if(!(componentMetadata.extension&&componentMetadata.extension.oracle&&componentMetadata.extension.oracle.businessApprovals)){issue=new context.Issue(`Component is missing PLS Business Approval Information relating to the reference '${dependency}'`);issue.setMsgKey('jetwco-thirdparty-ba_1');context.reporter.addIssue(issue,context,'major')}else{Object.keys(referencedLibs).forEach(lib=>{if(!componentMetadata.extension.oracle.businessApprovals.hasOwnProperty(lib)){issue=new context.Issue(`Component is missing PLS Business Approval Information relating to '${lib}' from '${dependency}'`);issue.setMsgKey('jetwco-thirdparty-ba_2');context.reporter.addIssue(issue,context,'major')}else{if(componentMetadata.extension.oracle.businessApprovals[lib]!==referencedLibs[lib]){issue=new context.Issue(`Component PLS Business Approval Information relating to '${lib}' from '${dependency}' does not match`);issue.setMsgKey('jetwco-thirdparty-ba_2');context.reporter.addIssue(issue,context,'major')}}})}}else{issue=new context.Issue(`Reference component dependency '${dependency}' does not have supplied PLS Business Approval Information`);issue.setMsgKey('jetwco-thirdparty-ba_3');context.reporter.addIssue(issue,context,'major')}}})}if(componentType==='reference'){if(!(componentMetadata.extension&&componentMetadata.extension.oracle&&componentMetadata.extension.oracle.businessApprovals)){issue=new context.Issue(`Reference component is missing PLS Business Approval Information`,'0008');context.reporter.addIssue(issue,context,'major')}}}};module.exports=ruleDef;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2018, 2021, Oracle and/or its affiliates.
|
|
3
|
+
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
|
+
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
|
+
*/
|
|
6
|
+
{"jetwco-component-cdn":"0001","jetwco-license-info_1":"0002","jetwco-license-info_2":"0003","jetwco-prerelease-cdn":"0004","jetwco-thirdparty-ba_1":"0005","jetwco-thirdparty-ba_2":"0006","jetwco-thirdparty-ba_3":"0007","jetwco-exchange-version-check_1":"0009","jetwco-exchange-version-check_2":"0010","jetwco-component-api-changes":"0011","jetwco-compjson-ns-reg":"0012","jetwco-component-api-baseline-changes":"0013"}
|
|
@@ -1 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2018, 2021, Oracle and/or its affiliates.
|
|
3
|
+
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
|
+
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
|
+
*/
|
|
6
|
+
{"title":"Oracle Internal Audit Rules for JET Custom Component Authors","prefix":"JETWCO","version":"1.8.1","rules":{"jetwco-bootstrap":{"group":"jetwco-do-not-disable","enabled":true,"severity":"info","debug":false,"diagnosticFile":"jetwco-diagnostics","componentRoot":"jet-composites","auditBuildOutput":false},"jetwco-component-cdn":{"group":"jetwco-pre-release","severity":"major","filetype":["json"]},"jetwco-prerelease-cdn":{"group":"jetwco-pre-release","enabled":true,"cdnRoot":"https://static.oracle.com/cdn/","severity":"blocker","filetype":["json"]},"jetwco-thirdparty-ba":{"group":"jetwco-pre-release","enabled":true,"severity":"major","filetype":["json","tsx"]},"jetwco-license-info":{"group":"jetwco-pre-release","enabled":true,"severity":"blocker","filetype":["json","tsx"]},"jetwco-exchange-version-check":{"group":"jetwco-api","enabled":false,"severity":"info","filetype":["json","tsx"]},"jetwco-component-api-changes":{"group":"jetwco-api","enabled":false,"severity":"blocker","filetype":["json"],"clearCache":false},"jetwco-compjson-ns-reg":{"group":"jetwco-api","enabled":true,"severity":"blocker","filetype":["json","tsx"]},"jetwco-component-api-baseline-changes":{"group":"jetwco-api","enabled":false,"severity":"blocker","filetype":["json"],"baseline":{},"clearCache":false}}}
|
|
@@ -1 +1,6 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2018, 2021, Oracle and/or its affiliates.
|
|
3
|
+
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
|
+
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
|
+
*/
|
|
1
6
|
{"spoc-dom-manip":"0010","spoc-dom-manip-inv-tag":"0020","spoc-dom-manip-tag-pos":"0030"}
|
|
@@ -1 +1,6 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2018, 2021, Oracle and/or its affiliates.
|
|
3
|
+
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
|
+
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
|
+
*/
|
|
1
6
|
{"title":"Security Point of Contact Rule Pack","prefix":"SPOC","version":"1.2.0","rules":{"spoc-dom-manip":{"severity":"blocker","filetype":"js","group":"spoc","status":"ready","settings":{"new":{"show":true,"showGetters":false},"existing":{"showUpdate":false,"showXSS":false,"showRandom":false,"showOkUntagged":false}}},"spoc-dom-manip-inv-tag":{"severity":"blocker","filetype":"js","group":"spoc","status":"ready"},"spoc-dom-manip-tag-pos":{"severity":"blocker","filetype":"js","group":"spoc","status":"ready"}}}
|
|
@@ -1 +1,6 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2018, 2021, Oracle and/or its affiliates.
|
|
3
|
+
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
|
+
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
|
+
*/
|
|
1
6
|
const RULE_NAME="spoc-dom-manip-inv-tag";const TAG_OK="@HTMLUpdateOK";const TAG_REVIEW="@HTMLUpdateReview";const TAG_XSS_FALSE_POSITIVE="@XSSFalsePositive";const TAG_RANDOM="@RandomNumberOK";const TAG_OK_LC="@htmlupdateok";const TAG_REVIEW_LC="@htmlupdatereview";const TAG_XSS_FALSE_POSITIVE_LC="@xssfalsepositive";const TAG_RANDOM_LC="@randomnumberok";const REGEX=/@HTML/gi;const REGEX2=/@XSS/gi;const REGEX3=/@Rand/gi;function Rule(){};Rule.prototype.getName=function(){return RULE_NAME};Rule.prototype.getShortDescription=function(){return"Finds all uses of SPOC tags with incorrect case"};Rule.prototype.getDescription=function(){return"Finds all uses of SPOC tags '@HTMLUpdateOK', '@HTMLUpdateReview', '@XSSFalsePositive' and '@RandomNumberOK' with incorrect case"};Rule.prototype.register=function(){return{"file":_scan}};function _scan(context){var data=context.data,tag,lcTag,s,issue,result,indices=[],i,x;REGEX.lastIndex=0;while(result=REGEX.exec(data)){indices.push(result.index)}REGEX2.lastIndex=0;while(result=REGEX2.exec(data)){indices.push(result.index)}REGEX3.lastIndex=0;while(result=REGEX3.exec(data)){indices.push(result.index)}for(i=0;i<indices.length;i++){x=indices[i];tag=_getTag(context,data,x);lcTag=tag.toLowerCase();if(lcTag.startsWith(TAG_OK_LC)||lcTag.startsWith(TAG_REVIEW_LC)||lcTag.startsWith(TAG_XSS_FALSE_POSITIVE_LC)||lcTag.startsWith(TAG_RANDOM_LC)){s=lcTag.substring(lcTag.length-1);if(s!=="k"&&s!=="w"&&s!=="e"){issue=new context.Issue("Remove trailing extraneous character(s) from '"+tag+"'");_updatePosition(context,issue,data,x,x+tag.length);context.reporter.addIssue(issue,context);continue}}else{issue=new context.Issue("Invalid security tag - '"+tag+"'");_updatePosition(context,issue,data,x,x+tag.length);context.reporter.addIssue(issue,context);continue}if(tag!==TAG_OK&&tag!==TAG_REVIEW&&tag!==TAG_XSS_FALSE_POSITIVE&&tag!==TAG_RANDOM&&!lcTag.startsWith(TAG_REVIEW_LC)){issue=new context.Issue("Invalid security tag case - '"+tag+"' - should be "+(lcTag.includes("review")?TAG_REVIEW:lcTag.includes("xss")?TAG_XSS_FALSE_POSITIVE:lcTag.includes("random")?TAG_RANDOM:TAG_OK));_updatePosition(context,issue,data,x,x+tag.length);context.reporter.addIssue(issue,context)}}};function _getTag(context,data,x){var i=context.utils.utils.getIndexToWhitespace(data,x);return data.substring(x,i)};function _updatePosition(context,issue,data,indexStart,indexEnd){var rowcol=context.utils.utils.getRowColFromIndex(data,indexStart);issue.setPosition(rowcol.row,rowcol.col,indexStart,indexEnd)};module.exports=Rule;
|
|
@@ -1 +1,6 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2018, 2021, Oracle and/or its affiliates.
|
|
3
|
+
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
|
+
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
|
+
*/
|
|
1
6
|
const RULE_NAME="spoc-dom-manip-tag-pos";const PROP_NAMES=[".innerHTML",".outerHTML"];const FUNC_NAMES=[".html",".prepend",".prependTo",".before",".after",".insertBefore",".insertAfter",".append",".appendTo",".wrap",".wrapAll",".wrapInner",".replaceAll",".replaceWith",".write",".writeln",".attr",".setAttribute",".cookie","eval","Function","setTimeout","setInterval","random","script","createElement",".appendChild","XMLHttpRequest","ActiveXObject"];const REGEX=/@HTML/gi;const REGEX2=/@XSS/gi;const REGEX3=/@Rand/gi;function Rule(){};Rule.prototype.getName=function(){return RULE_NAME};Rule.prototype.getShortDescription=function(){return"Finds all SPOC tags with invalid placement"};Rule.prototype.getDescription=function(){return"Finds all declarations of SPOC tags '@HTMLUpdateOK' and '@XSS_FALSE_POSITIVE' on lines that do not containg DOM manipulation properties or functions."};Rule.prototype.register=function(){return{"file":_scan}};function _scan(context){var data=context.data,tag,line,hit,issue,result,indices=[],i,j,x;REGEX.lastIndex=0;while(result=REGEX.exec(data)){indices.push(result.index)}REGEX2.lastIndex=0;while(result=REGEX2.exec(data)){indices.push(result.index)}REGEX3.lastIndex=0;while(result=REGEX3.exec(data)){indices.push(result.index)}for(i=0;i<indices.length;i++){x=indices[i];tag=_getTag(context,data,x);line=_getLineStart(context,data,x);hit=false;for(j=0;j<FUNC_NAMES.length;j++){if(line.includes(FUNC_NAMES[j])){hit=true;break}}if(!hit){for(j=0;j<PROP_NAMES.length;j++){if(line.includes(PROP_NAMES[j])){hit=true;break}}}if(tag.toLowerCase().includes("review")){issue=new context.Issue("obsolete tag '@HTMLUpdateReview' - remove");_updatePosition(context,issue,data,x,x+tag.length);context.reporter.addIssue(issue,context)}else if(!hit){issue=new context.Issue("Incorrect placement of '"+tag+"'");_updatePosition(context,issue,data,x,x+tag.length);context.reporter.addIssue(issue,context)}}};function _getTag(context,data,x){var i=context.utils.utils.getIndexToWhitespace(data,x);return data.substring(x,i)};function _getLineStart(context,data,x){var i,ret=null;for(i=x;i>=0;i--){if(data.charAt(i)==="\n"){ret=data.substring(i,x);break}}return ret};function _updatePosition(context,issue,data,indexStart,indexEnd){var rowcol=context.utils.utils.getRowColFromIndex(data,indexStart);issue.setPosition(rowcol.row,rowcol.col,indexStart,indexEnd)};module.exports=Rule;
|
|
@@ -1 +1,6 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2018, 2021, Oracle and/or its affiliates.
|
|
3
|
+
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
|
+
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
|
+
*/
|
|
1
6
|
const RULE_NAME="spoc-dom-manip";const PROP_NAMES=["innerHTML","outerHTML"];const FUNCS_DOM_MANIP=["html","prepend","prependTo","before","after","insertAfter","append","appendTo","wrap","wrapAll","wrapInner","replaceAll","replaceWith","write","writeln","attr","setAttribute"];const FUNCS_OF_INTEREST=["eval","Function","setTimeout","setInterval","random","createElement","write","writeln"];const FUNCS_SPECIAL_CASE=["appendChild"];const FUNCS_AJAX=["XMLHttpRequest","ActiveXObject"];const SAFE_ATTR_NAMES=["align","alink","alt","bgcolor","border","cellpadding","cellspacing","class","color","cols","colspan","coords","dir","face","height","hspace","id","ismap","lang","marginheight","marginwidth","multiple","nohref","noresize","noshade","nowrap","ref","rel","rev","role","rows","rowspan","scrolling","shape","span","summary","tabindex","title","usemap","valign","value","vlink","vspace","width"];const UNSAFE_ATTR_NAMES=["action","allow","async","background","charset","cite","data","formaction","icon","ping","poster","src","srcdoc","srcset","style"];const FUNC_EXPR="FunctionExpression";const ARROW_FUNC_EXPR="ArrowFunctionExpression";const IDENTIFIER="Identifier";const LITERAL="Literal";const BLOCK_STMT="BlockStatement";const CALL_EXPR="CallExpression";const MEMBER_EXPR="MemberExpression";const TAG_OK="@htmlupdateok";const TAG_REVIEW="@htmlupdatereview";const TAG_XSS_F_POS="@xssfalsepositive";const TAG_RANDOM="@randomnumberok";function Rule(){};Rule.prototype.getName=function(){return RULE_NAME};Rule.prototype.getShortDescription=function(){return"Reports DOM manipulations in JS"};Rule.prototype.getDescription=function(){return"Reports on DOM manipulations and optionally provides the ability to tag with @HTMLUpdateOK."};Rule.prototype.register=function(regContext){this._settings=regContext.ruleOpts.settings;return{AssignmentExpression:this._handleDom,CallExpression:this._handleCall,NewExpression:this._handleNewExpr,MemberExpression:this._handleMemExpr,VariableDeclaration:this._handleVarDecl,VariableDeclarator:this._handleVarDecl}};Rule.prototype._handleDom=function(context,node){if(node.left){this._handleDom2(context,node.left,node.right,true)}};Rule.prototype._handleMemExpr=function(context,node){var obj,funcName;if(node.parent&&node.parent.type==="ConditionalExpression"){obj=node.parent;if(obj.consequent&&obj.consequent.property&&obj.consequent.property.type===IDENTIFIER){obj=obj.consequent.property;if(isDomManip(obj.name)){if(this._settings.new.showGetters){this._checkAndEmit(context,obj,{msg:"DOM manipulation getter '"+obj.name+"'"})}}else if(isDomManipFunc(obj.name)){funcName:obj.property&&obj.property.type===IDENTIFIER?obj.property.name:obj.name;if(funcName){this._checkAndEmit(context,obj,{isFunc:true,funcName:funcName,msg:"DOM manipulation function "+funcName+"()"})}}else if(isFuncOfInterest(obj.name)){this._checkAndEmit(context,obj,{funcName:obj.property&&obj.property.type===IDENTIFIER?obj.property.name:obj.name,isFunc:true,funcName:funcName,msg:"DOM manipulation function "+funcName+"()"})}}if(obj.alternate&&obj.alternate.property&&obj.alternate.property.type===IDENTIFIER){obj=obj.alternate.property;if(isDomManip(obj.name)){if(this._settings.new.showGetters){this._checkAndEmit(context,obj,{msg:"DOM manipulation getter '"+obj.name+"'"})}}else if(isDomManipFunc(obj.name)){funcName=obj.property&&obj.property.type===IDENTIFIER?obj.property.name:obj.name;this._checkAndEmit(context,obj,{isFunc:true,funcName:funcName,msg:"DOM manipulation function "+funcName+"()"})}}}else{this._checkCookie(context,node)}};Rule.prototype._handleCall=function(context,node){var obj,funcOfInterest,funcName;if(node.callee){obj=node.callee.property?node.callee.property:node.callee;funcName=obj.name;funcOfInterest=isFuncOfInterest(funcName);if(isDomManipFunc(funcName)||funcOfInterest){if(this._checkHtmlFunc(context,node)||this._checkDocumentWrite(context,node)||this._checkCreateElement(context,node)||this._checkTimeFuncs(context,node)||this._checkMathRandom(context,node)||this._checkEval(context,node)||this._checkSafeSetAttrName(context,node)){return}this._checkAndEmit(context,obj,{isFunc:true,funcName:funcName,msg:(!funcOfInterest?"DOM manipulation ":"")+"function "+funcName+"()"})}}};Rule.prototype._handleNewExpr=function(context,node){var callee,funcName;if(node.callee){callee=node.callee;if(isFuncAjax(callee.name)){funcName=_getFuncName(callee);this._checkAndEmit(context,callee,{isFunc:true,funcName:funcName,msg:"function "+funcName+"()"})}else{if(callee.type===IDENTIFIER&&callee.name==="Function"){funcName=_getFuncName(callee);this._checkAndEmit(context,callee,{isFunc:true,funcName:funcName,msg:"function "+funcName+"()"})}}}};Rule.prototype._handleDom2=function(context,nodeLeft,nodeRight,isSetter){var node;if(nodeLeft.property){node=nodeLeft.property;if(node.type===IDENTIFIER){if(isDomManip(node.name)){if(!this._checkAssignedValue(context,nodeRight)){if(isSetter||this._settings.new.showGetters){this._checkAndEmit(context,node,{msg:"DOM manipulation "+(isSetter?"setter":"getter")+" '"+node.name+"'"})}}}}}else if(nodeRight.type===LITERAL&&nodeRight.value==="script"){this._checkAndEmit(context,nodeRight,{msg:"var assignment of 'script'"})}};Rule.prototype._handleVarDecl=function(context,node){var i,decl;if(node.declarations){for(i=0;i<node.declarations.length;i++){decl=node.declarations[i];if(!decl.init){continue}if(decl.init.type===LITERAL&&decl.init.value==="script"){this._checkAndEmit(context,decl,{isFunc:false,msg:"var '"+decl.id.name+"' initialized with 'script'"})}}}};Rule.prototype._check=function(context,obj,isFunc,setter,isDomManipFunc,isVar,isScriptAssign,isCookie){var line,tagType,tagged,isTagged,funcName,issue,rowcol;var utils=context.utils.utils;line=isolateLine(context.data,obj.end);tagType=getLineTag(line);tagged=tagType===TAG_OK?"UpdateOK tagged":tagType===TAG_XSS_F_POS?"XSS tagged":tagType===TAG_RANDOM?"RandomOK tagged":"untagged";isTagged=tagged!=="untagged";if(tagType===TAG_REVIEW){issue=new context.Issue("SPOC - obsolete tag '@HTMLUpdateReview' - remove");issue.setSeverity("info");rowcol=utils.getRowColFromIndex(context.data,obj.start);issue.setPosition(rowcol.row,rowcol.col,obj.start,obj.end);context.reporter.addIssue(issue,context);issue=null;tagType=""}if(isFunc){funcName=obj.property&&obj.property.type===IDENTIFIER?obj.property.name:obj.name;if(funcName==="random"&&tagType&&tagType!==TAG_RANDOM){issue=new context.Issue("SPOC - Math.random() is tagged incorrectly (use '@RandomNumberOK')");context.reporter.addIssue(issue,context);return}}if(!tagType&&this._settings.new.show||tagType===TAG_OK&&this._settings.existing.showUpdate||tagType===TAG_XSS_F_POS&&this._settings.existing.showXSS||tagType===TAG_RANDOM&&this._settings.existing.showRandom){issue=null;if(isFunc){issue=new context.Issue("SPOC - "+tagged+(isDomManipFunc?"DOM manipulation":"")+" function "+funcName+"()")}else if(isVar){issue=new context.Issue("SPOC - "+tagged+" var '"+obj.id.name+"' initialized with 'script'")}else if(isScriptAssign){issue=new context.Issue("SPOC - "+tagged+" var assignment of 'script'")}else if(isCookie){issue=new context.Issue("SPOC - "+tagged+" use of 'document.cookie'")}else if(setter||this._settings.new.showGetters){issue=new context.Issue("SPOC - "+tagged+" DOM manipulation "+(setter?"setter":"getter")+" '"+obj.name+"'")}if(issue){rowcol=utils.getRowColFromIndex(context.data,obj.property?obj.property.start:obj.start);issue.setPosition(rowcol.row,rowcol.col,obj.start,obj.end);if(isTagged){issue.setSeverity("info")}context.reporter.addIssue(issue,context)}}};Rule.prototype._checkAndEmit=function(context,obj,info){var line,tagType,tagged,isTagged,issue,rowcol;var utils=context.utils.utils;line=isolateLine(context.data,obj.end);tagType=getLineTag(line);tagged=tagType===TAG_OK?"UpdateOK tagged":tagType===TAG_XSS_F_POS?"XSS tagged":tagType===TAG_RANDOM?"RandomOK tagged":"untagged";isTagged=tagged!=="untagged";if(tagType===TAG_REVIEW){issue=new context.Issue("SPOC - obsolete tag '@HTMLUpdateReview' - remove");issue.setSeverity("info");rowcol=utils.getRowColFromIndex(context.data,obj.start);issue.setPosition(rowcol.row,rowcol.col,obj.start,obj.end);context.reporter.addIssue(issue,context);issue=null;tagType=""}issue=null;if(info.funcName){}if(!tagType&&this._settings.new.show||tagType===TAG_OK&&this._settings.existing.showUpdate||tagType===TAG_XSS_F_POS&&this._settings.existing.showXSS||tagType===TAG_RANDOM&&this._settings.existing.showRandom){issue=new context.Issue("SPOC - "+tagged+" "+info.msg);if(issue){rowcol=utils.getRowColFromIndex(context.data,obj.property?obj.property.start:obj.start);issue.setPosition(rowcol.row,rowcol.col,obj.start,obj.end);if(isTagged){issue.setSeverity("info")}context.reporter.addIssue(issue,context)}}};Rule.prototype._checkFuncOKUntagged=function(context,obj){var line,tagType,issue,rowcol;if(!this._settings.existing.showOkUntagged){return}line=isolateLine(context.data,obj.end);tagType=getLineTag(line);if(!tagType&&this._settings.new.show||tagType!==TAG_OK&&this._settings.existing.showUpdate||tagType!==TAG_XSS_F_POS&&this._settings.existing.showXSS){issue=new context.Issue("SPOC - "+" DOM manipulation function "+obj.name+"() is OK, but untagged");if(issue){rowcol=context.utils.utils.getRowColFromIndex(context.data,obj.start);issue.setPosition(rowcol.row,rowcol.col,obj.start,obj.end);issue.setSeverity("info");context.reporter.addIssue(issue,context)}}};Rule.prototype._checkAssignedValue=function(context,node){var v,ret=false;if(node.type===LITERAL){v=node.value;if(context.utils.utils.getType(v)==="string"){if(v===""){ret=true}}}return ret};Rule.prototype._checkHtmlFunc=function(context,node){var callee,ret=false;callee=node.callee;if(callee.property&&callee.property.type===IDENTIFIER){if(callee.property.name==="html"){if(node.arguments&&node.arguments.length){this._checkAndEmit(context,callee.property,{isFunc:true,funcName:"html",msg:"DOM manipulation function html() used as a setter"})}ret=true}}return ret};Rule.prototype._checkDocumentWrite=function(context,node){var callee,meth,ret=false;callee=node.callee;if(callee.property&&callee.property.type===IDENTIFIER){meth=callee.property.name;if(meth==="write"||meth==="writeln"){if(callee.type===MEMBER_EXPR&&callee.object.type===IDENTIFIER&&callee.object.name==="document"){this._checkAndEmit(context,callee.property,{isFunc:true,funcName:meth,msg:"DOM manipulation function document."+meth+"()"});ret=true}}}return ret};Rule.prototype._checkCreateElement=function(context,node){var callee,meth,args,arg,ret=false;callee=node.callee;if(callee.property&&callee.property.type===IDENTIFIER){meth=callee.property.name;if(meth==="createElement"){if(true){args=node.arguments;if(args.length>=1){arg=args[0];if(arg.type===LITERAL){if(arg.value!=="script"){return true}else{this._checkAndEmit(context,callee.property,{isFunc:true,funcName:"createElement",msg:"function createElement() used to create a 'script' element"})}return true}else if(arg.type==="ConditionalExpression"){if(arg.consequent.type===LITERAL&&arg.consequent.value!=="script"&&arg.alternate.type===LITERAL&&arg.alternate.value!=="script"){return true}}}this._checkAndEmit(context,callee.property,{isFunc:true,funcName:"createElement",msg:"function createElement() may potentially be used to create a 'script' element"});ret=true}}}return ret};Rule.prototype._checkCookie=function(context,node){var obj,prop,ret=false;obj=node.object;if(obj&&obj.type===IDENTIFIER&&obj.name==="document"){prop=node.property;if(prop&&prop.type===IDENTIFIER&&prop.name==="cookie"){this._checkAndEmit(context,prop,{msg:"use of 'document.cookie'"});ret=true}}return ret};Rule.prototype._checkAppendChild=function(context,node){var callee,meth,obj,ret=false;callee=node.callee;if(callee.property&&callee.property.type===IDENTIFIER){meth=callee.property.name;if(meth==="appendChild"){if(callee.type===MEMBER_EXPR&&callee.object.type===IDENTIFIER&&callee.object.name==="document"){obj=callee.object;if(obj.property&&obj.property.type===IDENTIFIER&&obj.name==="head"){this._checkAndEmit(context,callee.property,{isFunc:true,funcName:"appendchild",msg:"DOM manipulation function appendChild()"});ret=true}}else{this._checkAndEmit(context,callee.property,{isFunc:true,funcName:"appendChild",msg:"DOM manipulation function appendChild()"});ret=true}}}return ret};Rule.prototype._checkTimeFuncs=function(context,node){var obj,callee,meth,args,arg,ret=false;callee=node.callee;obj=callee.property?callee.property:callee;if(obj.type===IDENTIFIER){meth=obj.name;if(meth!=="setTimeout"&&meth!=="setInterval"){return false}if(node.arguments){args=node.arguments;if(args.length>=1){arg=args[0];if(arg.type!==FUNC_EXPR&&arg.type!==ARROW_FUNC_EXPR){if(arg.type===LITERAL||arg.type===CALL_EXPR||!_isIdentAFunc(node,arg.name)){this._checkAndEmit(context,callee,{isFunc:false,funcName:meth,msg:"function "+meth+"()"})}}else{}ret=true}}}return ret};Rule.prototype._checkMathRandom=function(context,node){var obj,callee,meth,ret=false;callee=node.callee;obj=callee.property?callee.property:callee;if(callee.object&&callee.object.type===IDENTIFIER&&callee.object.name==="Math"){meth=obj.name;if(meth==="random"){this._checkAndEmit(context,obj,{isFunc:true,funcName:"Math.random",msg:"function Math.random()"});ret=true}}return ret};Rule.prototype._checkEval=function(context,node){var obj,callee,meth,ret=false;callee=node.callee;obj=callee.property?callee.property:callee;meth=obj.name;if(meth==="eval"){this._checkAndEmit(context,obj,{isfunc:true,funcName:"eval",msg:"function eval()"});ret=true}return ret};Rule.prototype._checkAjax=function(context,node){var obj,callee,meth,ret=false;callee=node.callee;obj=callee.property?callee.property:callee;meth=obj.name;if(meth==="XMLHttpRequest"||meth==="ActiveXObject"){this._checkAndEmit(context,obj,{isFunc:true,funcName:meth,msg:"function "+meth+"()"});ret=true}return ret};Rule.prototype._checkSafeSetAttrName=function(context,node){var callee,meth,args,arg,msg,ret=false;callee=node.callee;if(callee.property&&callee.property.type===IDENTIFIER){meth=callee.property.name;if(meth==="setAttribute"||meth==="attr"){args=node.arguments;if(args.length<2){return true}arg=args[0];if(arg.type===LITERAL){if(isSafeSetAttrName(arg.value,meth==="setAttribute")){return true}if(isUnsafeSetAttrName(arg.value,args[1].value)){if(arg.value.startsWith("on")){if(context.utils.utils.getType(args[1])==="function"){this._checkFuncOKUntagged(context,callee.property)}else{this._checkAndEmit(context,callee.property,{isFunc:true,funcName:meth,msg:"function "+meth+"('"+arg.value+"', ...)"})}}else{this._checkAndEmit(context,callee.property,{isFunc:true,funcName:meth,msg:"function "+meth+"('"+arg.value+"', ...)"})}}ret=true}if(!ret){if(args&&args.length){if(args[0].type===LITERAL){msg=args[0].raw+", ..."}else{msg="expr, ... "}}this._checkAndEmit(context,callee.property,{isFunc:true,funcName:meth,msg:"function "+meth+"("+msg+")"});ret=true}}}return ret};function isDomManip(name){return PROP_NAMES.includes(name)};function isDomManipFunc(name){return FUNCS_DOM_MANIP.includes(name)};function isFuncOfInterest(name){return FUNCS_OF_INTEREST.includes(name)};function isFuncAjax(name){return FUNCS_AJAX.includes(name)};function isSpecialCaseFunc(name){return FUNCS_SPECIAL_CASE.includes(name)};function isSafeSetAttrName(name,isSetAttribute){return name.startsWith("data-")||name.startsWith("aria-")||SAFE_ATTR_NAMES.includes(name)||name==="for"||name.startsWith("oj-")};function isUnsafeSetAttrName(attr,value){value=value||"";if(typeof value==="string"){value=value.trim()}return attr.startsWith("on")||UNSAFE_ATTR_NAMES.includes(attr)||attr==="href"&&value!=="#"&&value!==""};function _getFuncName(obj){return obj.property&&obj.property.type===IDENTIFIER?obj.property.name:obj.name};function _isIdentAFunc(node,funcName){var n,decls,decl,i,j,isFunc=false;node=node.parent;while(node){if(!node){break}if(node.type!==BLOCK_STMT){if(node.type!=="Program"){node=node.parent;continue}for(i=0;i<node.body.length;i++){n=node.body[i];if(n.type==="FunctionDeclaration"){isFunc=n.id&&n.id.type===IDENTIFIER&&n.id.name===funcName;if(isFunc){return true}}}return false}if(node.body){for(i=0;i<node.body.length;i++){n=node.body[i];if(n.type==="FunctionDeclaration"){isFunc=n.id&&n.id.type===IDENTIFIER&&n.id.name===funcName;if(isFunc){return true}}}for(i=0;i<node.body.length;i++){n=node.body[i];if(n.type==="VariableDeclaration"){decls=n.declarations;if(decls){for(j=0;j<decls.length;j++){decl=decls[j];if(decl.type==="VariableDeclarator"){if(decl.id.type===IDENTIFIER&&decl.id.name===funcName){return decl.init&&(decl.init.type===FUNC_EXPR||decl.init.type===ARROW_FUNC_EXPR)}}}}isFunc=n.id&&n.id.type===IDENTIFIER&&n.id.name===funcName;if(isFunc){return true}}}}node=node.parent}return false};function isolateLine(data,endIndex){var i,c,len=data.length;for(i=endIndex;i<len;i++){c=data.charAt(i);if(c==="\n"||c==="\r"){break}}return data.substring(endIndex,i)};function getLineTag(line){var lc=line.toLowerCase();return lc.includes(TAG_OK)?TAG_OK:lc.includes(TAG_REVIEW)?TAG_REVIEW:lc.includes(TAG_XSS_F_POS)?TAG_XSS_F_POS:lc.includes(TAG_RANDOM)?TAG_RANDOM:""};module.exports=Rule;
|
|
@@ -1 +1,6 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2018, 2021, Oracle and/or its affiliates.
|
|
3
|
+
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
|
+
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
|
+
*/
|
|
1
6
|
function getName(){return"jaf-css-diagnose"};function getShortDescription(){return"Handle CSS syntax exceptions"};function getDescription(){return"While processing CSS, an exception has occurred, and is probably the result of a syntax specification error. Review the CSS for invalid syntax."};module.exports={getName,getDescription,getShortDescription};
|
|
@@ -1 +1,6 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2018, 2021, Oracle and/or its affiliates.
|
|
3
|
+
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
|
+
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
|
+
*/
|
|
1
6
|
function getName(){return"jaf-html-diagnose"};function getShortDescription(){return"Handle HTML syntax exceptions"};function getDescription(){return"While processing HTML, a syntax specification error was noted. Review the HTML for superfluous characters or invalid syntax."};module.exports={getName,getDescription,getShortDescription};
|
|
@@ -1 +1,6 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2018, 2021, Oracle and/or its affiliates.
|
|
3
|
+
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
|
+
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
|
+
*/
|
|
1
6
|
function getName(){return"jaf-init-schema"};function getShortDescription(){return"Handle initialization schema exceptions while reading web-component metadata"};function getDescription(){return"While processing user specified web component metadata during startup, schema validation issues were found in the associated component.json.<br>[Note: the line/column repoted is (0,0) because the schema valdator does not currently return this information.]"};module.exports={getName,getDescription,getShortDescription};
|
|
@@ -1 +1,6 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2018, 2021, Oracle and/or its affiliates.
|
|
3
|
+
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
|
+
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
|
+
*/
|
|
1
6
|
function getName(){return"jaf-js-diagnose"};function getShortDescription(){return"Handle Javascript syntax exceptions"};function getDescription(){return"While processing JavaScript, an exception has occurred, and is probably the result of a syntax specification error. Review the Javascript for invalid syntax."};module.exports={getName,getDescription,getShortDescription};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2018, 2021, Oracle and/or its affiliates.
|
|
3
|
+
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
|
+
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
|
+
*/
|
|
6
|
+
function getName(){return"jaf-ts-diagnose"};function getShortDescription(){return"Handle TypeScript syntax exceptions"};function getDescription(){return"While processing TypeScript, an exception has occurred, and is probably the result of a syntax specification error. Review the TypeScript for invalid syntax."};module.exports={getName,getDescription,getShortDescription};
|