r.plugin_rule_key as "ruleKey",
r.plugin_name as "repositoryKey",
r.description_format as "descriptionFormat",
r.status,
r.name,
r.plugin_config_key as "configKey",
r.priority as "severity",
r.is_template as "isTemplate",
r.is_external as "isExternal",
r.is_ad_hoc as "isAdHoc",
r.language as "language",
r.template_uuid as "templateUuid",
r.def_remediation_function as "defRemediationFunction",
r.def_remediation_gap_mult as "defRemediationGapMultiplier",
r.def_remediation_base_effort as "defRemediationBaseEffort",
r.gap_description as "gapDescription",
r.security_standards as "securityStandardsField",
r.rule_type as "type",
r.plugin_key as "pluginKey",
r.scope,
r.created_at as "createdAt",
r.updated_at as "updatedAt",
r.note_data as "noteData",
r.note_user_uuid as "noteUserUuid",
r.note_created_at as "noteCreatedAt",
r.note_updated_at as "noteUpdatedAt",
r.remediation_function as "remediationFunction",
r.remediation_gap_mult as "remediationGapMultiplier",
r.remediation_base_effort as "remediationBaseEffort",
r.ad_hoc_name as "adHocName",
r.ad_hoc_description as "adHocDescription",
r.ad_hoc_severity as "adHocSeverity",
r.ad_hoc_type as "adHocType",
r.education_principles as "educationPrinciplesField",
r.clean_code_attribute as "cleanCodeAttribute"
left outer join rule_desc_sections rds on
rds.rule_uuid = r.uuid
left outer join rules_default_impacts rdi on
rdi.rule_uuid = r.uuid
left outer join rule_tags rt on
rt.rule_uuid = r.uuid
rdi.rule_uuid as "rdi_ruleUuid",
rdi.software_quality as "rdi_softwareQuality",
rdi.severity as "rdi_severity",
CASE WHEN rt.is_system_tag = ${_true} THEN rt.value ELSE NULL END as rt_systemTags,
CASE WHEN rt.is_system_tag = ${_false} THEN rt.value ELSE NULL END as rt_tags,
rt.is_system_tag as "rt_isSystemTag",
rt.value as "rt_value",
rds.content as "rds_content",
rds.uuid as "rds_uuid",
rds.kee as "rds_kee",
rds.context_key as "rds_contextKey",
rds.context_display_name as "rds_contextDisplayName",
r.uuid as "r_uuid",
select
r.uuid as "ruleUuid",
r.plugin_name as "pluginName",
r.plugin_rule_key as "pluginRuleKey",
r.tags as "tags"
from rules r
where
r.tags is not null and
r.tags != ''
select
r.uuid as "ruleUuid",
r.plugin_name as "pluginName",
r.plugin_rule_key as "pluginRuleKey",
r.tags as "tags"
from rules r
where
r.tags is not null
r.status in ('READY', 'DEPRECATED', 'BETA')
and r.is_external=${_false}
and r.language=#{language, jdbcType=VARCHAR}
insert into rule_desc_sections (
uuid,
rule_uuid,
kee,
content,
context_key,
context_display_name
)
values (
#{dto.uuid,jdbcType=VARCHAR},
#{ruleUuid,jdbcType=VARCHAR},
#{dto.key,jdbcType=VARCHAR},
#{dto.content,jdbcType=VARCHAR},
#{dto.context.key,jdbcType=VARCHAR},
#{dto.context.displayName,jdbcType=VARCHAR}
)
insert into rules (
uuid,
plugin_key,
plugin_rule_key,
plugin_name,
description_format,
status,
name,
plugin_config_key,
priority,
is_template,
is_external,
is_ad_hoc,
language,
template_uuid,
def_remediation_function,
def_remediation_gap_mult,
def_remediation_base_effort,
gap_description,
security_standards,
rule_type,
scope,
note_data,
note_user_uuid,
note_created_at,
note_updated_at,
remediation_function,
remediation_gap_mult,
remediation_base_effort,
ad_hoc_name,
ad_hoc_description,
ad_hoc_severity,
ad_hoc_type,
education_principles,
clean_code_attribute,
created_at,
updated_at
)
values (
#{uuid,jdbcType=VARCHAR},
#{pluginKey,jdbcType=VARCHAR},
#{ruleKey,jdbcType=VARCHAR},
#{repositoryKey,jdbcType=VARCHAR},
#{descriptionFormat,jdbcType=VARCHAR},
#{status,jdbcType=VARCHAR},
#{name,jdbcType=VARCHAR},
#{configKey,jdbcType=VARCHAR},
#{severity,jdbcType=INTEGER},
#{isTemplate,jdbcType=BOOLEAN},
#{isExternal,jdbcType=BOOLEAN},
#{isAdHoc,jdbcType=BOOLEAN},
#{language,jdbcType=VARCHAR},
#{templateUuid,jdbcType=VARCHAR},
#{defRemediationFunction,jdbcType=VARCHAR},
#{defRemediationGapMultiplier,jdbcType=VARCHAR},
#{defRemediationBaseEffort,jdbcType=VARCHAR},
#{gapDescription,jdbcType=VARCHAR},
#{securityStandardsField,jdbcType=VARCHAR},
#{type,jdbcType=TINYINT},
#{scope,jdbcType=VARCHAR},
#{noteData,jdbcType=CLOB},
#{noteUserUuid,jdbcType=VARCHAR},
#{noteCreatedAt,jdbcType=BIGINT},
#{noteUpdatedAt,jdbcType=BIGINT},
#{remediationFunction,jdbcType=VARCHAR},
#{remediationGapMultiplier,jdbcType=VARCHAR},
#{remediationBaseEffort,jdbcType=VARCHAR},
#{adHocName,jdbcType=VARCHAR},
#{adHocDescription,jdbcType=CLOB},
#{adHocSeverity,jdbcType=VARCHAR},
#{adHocType,jdbcType=TINYINT},
#{educationPrinciplesField,jdbcType=VARCHAR},
#{cleanCodeAttribute,jdbcType=VARCHAR},
#{createdAt,jdbcType=BIGINT},
#{updatedAt,jdbcType=BIGINT}
)
INSERT INTO rules_default_impacts (rule_uuid, software_quality, severity)
VALUES (
#{ruleUuid,jdbcType=VARCHAR},
#{dto.softwareQuality,jdbcType=VARCHAR},
#{dto.severity,jdbcType=VARCHAR})
INSERT INTO rule_tags (rule_uuid, value, is_system_tag)
VALUES (
#{ruleUuid,jdbcType=VARCHAR},
#{value,jdbcType=VARCHAR},
#{isSystemTag,jdbcType=BOOLEAN})
update rules set
plugin_key=#{pluginKey,jdbcType=VARCHAR},
plugin_rule_key=#{ruleKey,jdbcType=VARCHAR},
plugin_name=#{repositoryKey,jdbcType=VARCHAR},
description_format=#{descriptionFormat,jdbcType=VARCHAR},
status=#{status,jdbcType=VARCHAR},
name=#{name,jdbcType=VARCHAR},
plugin_config_key=#{configKey,jdbcType=VARCHAR},
priority=#{severity,jdbcType=INTEGER},
is_template=#{isTemplate,jdbcType=BOOLEAN},
is_external=#{isExternal,jdbcType=BOOLEAN},
is_ad_hoc=#{isAdHoc,jdbcType=BOOLEAN},
language=#{language,jdbcType=VARCHAR},
template_uuid=#{templateUuid,jdbcType=VARCHAR},
def_remediation_function=#{defRemediationFunction,jdbcType=VARCHAR},
def_remediation_gap_mult=#{defRemediationGapMultiplier,jdbcType=VARCHAR},
def_remediation_base_effort=#{defRemediationBaseEffort,jdbcType=VARCHAR},
gap_description=#{gapDescription,jdbcType=VARCHAR},
security_standards=#{securityStandardsField,jdbcType=VARCHAR},
scope=#{scope,jdbcType=VARCHAR},
rule_type=#{type,jdbcType=TINYINT},
note_data=#{noteData,jdbcType=CLOB},
note_user_uuid=#{noteUserUuid,jdbcType=VARCHAR},
note_created_at=#{noteCreatedAt,jdbcType=BIGINT},
note_updated_at=#{noteUpdatedAt,jdbcType=BIGINT},
remediation_function=#{remediationFunction,jdbcType=VARCHAR},
remediation_gap_mult=#{remediationGapMultiplier,jdbcType=VARCHAR},
remediation_base_effort=#{remediationBaseEffort,jdbcType=VARCHAR},
ad_hoc_name=#{adHocName,jdbcType=VARCHAR},
ad_hoc_description=#{adHocDescription,jdbcType=CLOB},
ad_hoc_severity=#{adHocSeverity,jdbcType=VARCHAR},
ad_hoc_type=#{adHocType,jdbcType=TINYINT},
education_principles=#{educationPrinciplesField,jdbcType=VARCHAR},
clean_code_attribute=#{cleanCodeAttribute,jdbcType=VARCHAR},
updated_at=#{updatedAt,jdbcType=BIGINT}
where
uuid=#{uuid,jdbcType=VARCHAR}
delete from
rule_desc_sections
where
rule_uuid=#{ruleUuid,jdbcType=VARCHAR}
delete from
rules_default_impacts
where
rule_uuid=#{ruleUuid,jdbcType=VARCHAR}
delete from
rule_tags
where
rule_uuid=#{ruleUuid,jdbcType=VARCHAR}
delete from
active_rule_parameters
where
rules_parameter_uuid=#{uuid,jdbcType=VARCHAR}
p.uuid as "uuid",
p.rule_uuid as "ruleUuid",
p.name as "name",
p.param_type as "type",
p.default_value as "defaultValue",
p.description as "description"
delete from
rules_parameters
where
uuid=#{uuid,jdbcType=INTEGER}
insert into rules_parameters (
uuid,
rule_uuid,
name,
param_type,
default_value,
description
)
values (
#{uuid,jdbcType=VARCHAR},
#{ruleUuid,jdbcType=VARCHAR},
#{name,jdbcType=VARCHAR},
#{type,jdbcType=VARCHAR},
#{defaultValue,jdbcType=VARCHAR},
#{description,jdbcType=VARCHAR}
)
update rules_parameters set
param_type=#{type,jdbcType=VARCHAR},
default_value=#{defaultValue,jdbcType=VARCHAR},
description=#{description,jdbcType=VARCHAR}
where
uuid=#{uuid,jdbcType=VARCHAR}
DELETE FROM
deprecated_rule_keys
WHERE
uuid=#{uuid,jdbcType=INTEGER}
INSERT INTO deprecated_rule_keys (
uuid,
rule_uuid,
old_repository_key,
old_rule_key,
created_at
)
values (
#{uuid,jdbcType=VARCHAR},
#{ruleUuid,jdbcType=VARCHAR},
#{oldRepositoryKey,jdbcType=VARCHAR},
#{oldRuleKey,jdbcType=VARCHAR},
#{createdAt,jdbcType=BIGINT}
)
inner join active_rules ar on ar.rule_uuid = r.uuid
where
r.status != 'REMOVED'
and r.is_external = ${_false}
and r.created_at >= #{query.createdAt,jdbcType=BIGINT}
and r.language = #{query.language,jdbcType=VARCHAR}
and ar.profile_uuid = #{query.profileUuid,jdbcType=VARCHAR}