Skip to content

Commit 96678c2

Browse files
committed
initial commit
1 parent 2438805 commit 96678c2

File tree

845 files changed

+191328
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

845 files changed

+191328
-0
lines changed

controller.xml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<databaseChangeLog
3+
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
6+
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
7+
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
8+
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd
9+
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd
10+
http://www.liquibase.org/xml/ns/pro http://www.liquibase.org/xml/ns/pro/liquibase-pro-latest.xsd">
11+
12+
<!-- SERT property file with parameters -->
13+
<property file="sert.properties" contextFilter="standalone" />
14+
15+
<include
16+
file="product/sertController.xml"
17+
relativeToChangelogFile="true"/>
18+
19+
</databaseChangeLog>

development/.DS_Store

8 KB
Binary file not shown.

development/licence_snip.txt

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
-------------------------------------------------------------------------------
2+
-- Copyright (c) 2024 Oracle and/or its affiliates.
3+
-- Licensed under the Universal Permissive License v 1.0 as shown
4+
-- at https://oss.oracle.com/licenses/upl/
5+
--------------------------------------------------------------------------------

development/scripts/README.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Scripts Directory
2+
3+
Place ad-hoc type scripts in here.
4+
5+
Examples:
6+
7+
- reset
8+
- debugging
9+
- load testing
10+
- etc
11+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
for file in $(find ./product/sert/apex -type file -iname '*.sql' -exec grep -H -E -o -c "\-\-liquibase formatted sql" {} \; | sed 's/..$//')
3+
do
4+
if [ 0 -eq $(grep -c "Universal Permissive License" ${file} ) ]
5+
then
6+
ed -s ${file} <<<$'1r development/licence_snip.txt\nw'
7+
else
8+
echo "****** found license for ${file}"
9+
fi
10+
done
11+
# fix format trick
12+
#'
13+
# ed -s ${file} <<<$'0r development/licence_snip.txt\nw'
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
for file in $(find . -type file -iname '*.sql' -exec grep -H -E -o -c "\-\-liquibase formatted sql" {} \; | grep :1$| sed 's/..$//')
3+
do
4+
if [ 0 -eq $(grep -c "Universal Permissive License" ${file} ) ]
5+
then
6+
ed -s ${file} <<<$'1r development/licence_snip.txt\nw'
7+
else
8+
echo "****** found license for ${file}"
9+
fi
10+
done
11+
# fix format trick
12+
#'
13+
# ed -s ${file} <<<$'0r development/licence_snip.txt\nw'

development/scripts/ext.sql

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
--liquibase formatted sql
2+
-------------------------------------------------------------------------------
3+
-- Copyright (c) 2024 Oracle and/or its affiliates.
4+
-- Licensed under the Universal Permissive License v 1.0 as shown
5+
-- at https://oss.oracle.com/licenses/upl/
6+
--------------------------------------------------------------------------------
7+
8+
--changeset mipotter:tst_set_workspace_parameter_ALLOW_HOSTING_EXTENSIONS endDelimiter:/ runOnChange:true runAlways:true rollbackEndDelimiter:/
9+
begin
10+
sert_core.extension_xapi.allow_hosting( '${sert_apex_workspace}');
11+
end;
12+
/
13+
--changeset mipotter:tst_setup_builder_extension_add_menu_entry endDelimiter:/ runOnChange:true runAlways:true rollbackEndDelimiter:/
14+
begin
15+
sert_core.extension_xapi.add_menu_entry (
16+
p_url => 'r/${sert_apex_workspace}/apex_sert/home?session='||chr(38)||'APP_SESSION_ID.'||chr(38)||'P1_BUILDER_SESSION_ID='||chr(38)||'APP_SESSION_ID.',
17+
p_workspace =>'${sert_apex_workspace}',
18+
p_label => 'SERT 2.0'
19+
);
20+
end;
21+
/
22+
--rollback not required
23+
-- begin
24+
-- sert_core.extension_xapi.add_menu_entry (
25+
-- p_url => 'r/SERT/apex_sert/home?session='||chr(38)||'APP_SESSION_ID.'||chr(38)||'P1_BUILDER_SESSION_ID='||chr(38)||'APP_SESSION_ID.',
26+
-- p_workspace =>'SERT',
27+
-- p_label => 'SERT 2.0'
28+
-- );
29+
-- end;
30+
-- /
31+
32+
--changeset mipotter:tst_setup_builder_extension_grants endDelimiter:/ runOnChange:true runAlways:true rollbackEndDelimiter:/
33+
-- this can be enabled AFTER workspace parameter ALLOW_HOSTING_EXTENSIONS is set ( no automated until patch 24.1.2)
34+
BEGIN
35+
sert_core.extension_xapi.grant_extension_workspace ( p_to_workspace =>'${sert_apex_workspace}' );
36+
end;
37+
/
38+
--rollback not required
+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
2+
-- instance admin allow hosting extensions
3+
-- requires patch on ADB for bug 36753968
4+
--https://bug.oraclecorp.com/pls/bug/webbug_edit.edit_info_top?rptno=36753968&report_title=&rptno_count=19&pos=5&query_id=453900
5+
begin
6+
apex_instance_admin.set_workspace_parameter('SERT', 'ALLOW_HOSTING_EXTENSIONS', 'Y');
7+
end;
8+
/
9+
10+
-- https://docs.oracle.com/en/database/oracle/apex/24.1/aeapi/APEX_EXTENSION.ADD_MENU_ENTRY-Procedure.html#GUID-3F5696AC-5BCE-4915-9169-8F45D60ED28C
11+
BEGIN
12+
APEX_EXTENSION.ADD_MENU_ENTRY (
13+
p_label =>'APEX SERT',
14+
p_url => 'r/sert/sert/home?session=&APP_SESSION_ID.&P1_BUILDER_SESSION_ID=&APP_SESSION_ID.',
15+
p_display_sequence => 10,
16+
p_description => 'APEX SERT Security and standards scanner',
17+
p_is_public => true,
18+
p_workspace =>'SERT' )
19+
END;
20+
/
21+
22+
-- https://docs.oracle.com/en/database/oracle/apex/24.1/aeapi/GRANT_EXTENSION_WORKSPACE-Procedure.html#GUID-170786CB-23FF-43FB-BED6-F41E28029C1B
23+
BEGIN
24+
dbms_output.put_line('APEX version '||apex_application.g_flow_schema_owner);
25+
for rec in
26+
(select workspace from apex_workspaces aw
27+
where aw.workspace <> 'SERT'
28+
and not exists ( select workspace_name from apex_workspace_schemas ws
29+
where ws.workspace_name = aw.workspace and schema = apex_application.g_flow_schema_owner)
30+
minus
31+
select grantor_workspace workspace
32+
from apex_workspace_extension_grant
33+
where grantee_workspace = 'SERT' )
34+
loop
35+
dbms_output.put_line(rec.workspace);
36+
apex_instance_admin.grant_extension_workspace(
37+
p_from_workspace => rec.workspace,
38+
p_to_workspace => 'SERT',
39+
p_read_access => true
40+
);
41+
end loop;
42+
end;
43+
/
44+
45+
/*******************************************
46+
** statements in the workspace export.
47+
******************************************/
48+
49+
begin
50+
-- public API is APEX_EXTENSION.ADD_MENU_ENTRY
51+
wwv_imp_workspace.create_extension_link(
52+
p_id=>wwv_flow_imp.id(10395017022757818)
53+
,p_name=>'SERT Next' -- p_label
54+
,p_url=>'r/sert/sert/home?session=&APP_SESSION_ID.&P1_BUILDER_SESSION_ID=&APP_SESSION_ID.'
55+
,p_description=>'SERT Next'
56+
,p_display_sequence=>10
57+
,p_is_public=>true
58+
);
59+
end;
60+
/
61+
62+
prompt ... Extension Grants
63+
64+
begin
65+
wwv_flow_imp.import_end(p_auto_install_sup_obj => nvl(wwv_flow_application_install.get_auto_install_sup_obj, false)
66+
);
67+
commit;
68+
end;
69+
/
70+
71+
72+
prompt ... Extension Grants
73+
74+
begin
75+
wwv_imp_workspace.create_extension_grant(
76+
p_id=>wwv_flow_imp.id(10482516654792036)
77+
,p_extension_workspace=>'SERT'
78+
,p_has_read_access=>true
79+
);
80+
end;
81+
/
82+
begin
83+
wwv_flow_imp.import_end(p_auto_install_sup_obj => nvl(wwv_flow_application_install.get_auto_install_sup_obj, false)
84+
);
85+
commit;
86+
end;
87+
/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
set serverout on
2+
3+
DECLARE
4+
TYPE t_tab IS TABLE OF all_objects%ROWTYPE;
5+
l_tab t_tab;
6+
l_set CLOB;
7+
l_chr_lf VARCHAR2(1) := CHR(10);
8+
l_invalid_object VARCHAR2(255);
9+
l_sep VARCHAR2(50) := '--------------------------------------------------';
10+
BEGIN
11+
SELECT ao.*
12+
BULK COLLECT INTO l_tab
13+
FROM all_objects ao
14+
JOIN (SELECT trim(column_value) as schema_name
15+
FROM TABLE(APEX_STRING.SPLIT(property('PROJECT.PROJECT_SCHEMAS'), ':'))) ps
16+
ON ps.schema_name = ao.owner
17+
WHERE ao.status != 'VALID'
18+
AND ao.owner != 'INT_SUPPORT_PUB'
19+
ORDER BY ao.owner, object_name;
20+
21+
IF l_tab.exists(1) THEN
22+
DBMS_LOB.CREATETEMPORARY(lob_loc => l_set, cache => FALSE);
23+
FOR idx IN 1 .. l_tab.count
24+
LOOP
25+
l_invalid_object := l_tab(idx).object_type || ' : ' || l_tab(idx).owner || '.' || l_tab(idx).object_name;
26+
DBMS_OUTPUT.PUT_LINE('Invalid Object: ' || l_invalid_object);
27+
DBMS_LOB.WRITEAPPEND(lob_loc => l_set, amount => LENGTH(l_invalid_object || l_chr_lf), buffer => l_invalid_object || l_chr_lf);
28+
END LOOP;
29+
RAISE_APPLICATION_ERROR(
30+
-20001,
31+
'Invalid objects exist'
32+
|| l_chr_lf || l_sep
33+
|| l_chr_lf || SUBSTR(l_set, 1, 32767)
34+
|| l_chr_lf || l_sep
35+
);
36+
END IF;
37+
END;
38+
/

development/scripts/oci_grants.sql

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--liquibase formatted sql
2+
-------------------------------------------------------------------------------
3+
-- Copyright (c) 2024 Oracle and/or its affiliates.
4+
-- Licensed under the Universal Permissive License v 1.0 as shown
5+
-- at https://oss.oracle.com/licenses/upl/
6+
--------------------------------------------------------------------------------
7+
--changeset mzimon:oci_grants endDelimiter:/ runOnChange:true runAlways:false rollbackEndDelimiter:/
8+
--preconditions onFail:MARK_RAN onError:HALT
9+
-------------------------------------------------------------------------------
10+
-- this file should live in product/sert/sert_pub/grant/oci_grants.sql
11+
-- 06-jan-2025 moving to a development space to disable
12+
-------------------------------------------------------------------------------
13+
grant DWROLE to SERT_PUB
14+
/
15+
16+
begin
17+
dbms_cloud_admin.enable_resource_principal();
18+
dbms_cloud_admin.enable_resource_principal(username => 'SERT_PUB');
19+
end;
20+
/
21+
--rollback not required

development/scripts/push_release.sh

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#!/usr/bin/env bash
2+
set -o pipefail
3+
set -e
4+
5+
# There are cases where you want to build artifact in any given branch. In that
6+
# scenario - we use date string, but primarily this should always be driven from
7+
# the tag name.
8+
if [[ "${CI_COMMIT_TAG}" != "" ]]
9+
then
10+
buildVersion="${CI_COMMIT_TAG}"
11+
echo "Publishing artifacts for tag: ${CI_COMMIT_TAG}"
12+
else
13+
buildVersion=$(printf "%s_%s" "$(date -u +%y.%m.%d)" "${CI_PIPELINE_ID}")
14+
echo "Building artifacts for tag: ${buildVersion}"
15+
fi
16+
17+
targetFile="sert_${buildVersion}.zip"
18+
publishBaseUrl="${P_ARTIFACTORY_BASE_URL}/artifactory/xgbu-ace-dev/sert"
19+
apiBaseUrl="${P_ARTIFACTORY_BASE_URL}/api/storage/xgbu-ace-dev/sert"
20+
21+
# URL's for the version release (e.g. sert_23.11.01.zip)
22+
publishUrl="${publishBaseUrl}/${targetFile}"
23+
24+
# URL's for teh latest release (e.g. sert_latest.zip). Whenever doing a new build
25+
# we always duplicate the release file into a file ending in latest. This is so
26+
# people taking it up can always just grab the latest release, but we still have
27+
# a version history if anyone wanted to grab a specific version.
28+
publishUrlLatest="${publishBaseUrl}/sert_latest.zip"
29+
30+
# Create a temporary folder to copy files into that we want to form the zip/release
31+
# This file-set may evolve over time.
32+
tmpDir=$(mktemp -d -p .)
33+
34+
# Disable SC2086 because we want the product files to be read directly so it can
35+
# be sed to copy all the specified files, rather than being treated as a single
36+
# value.
37+
# shellcheck disable=SC2086
38+
cp -r ${PRODUCT_FILES} "${tmpDir}/"
39+
40+
# Substitute the version string in our release file
41+
sed -i "s|#DEVELOPMENT_BUILD#|${buildVersion}|g" "${tmpDir}/product/sert/sert_core/seed_data/055_prefs_internal_merge.sql"
42+
43+
(cd "${tmpDir}" && zip -r "../${targetFile}" ./*)
44+
45+
# We have no need for the temp folder now we have zipped up all the files
46+
rm -rf "${tmpDir}"
47+
48+
# Only publish the artifact to artifactory on tag pipeline
49+
if [[ "${CI_COMMIT_TAG}" != "" ]]
50+
then
51+
# Publishing process can include two files - the version bound to the tag name
52+
# and a separate version (which is the same file with a different name) using
53+
# -latest, so consumers can just always pull the latest.
54+
#
55+
# Additionally, the published file we will attach properties with the version
56+
# so consumers can do things programatically - and the short SHA of the reference
57+
# commit. This is helpful to go to the point in time in the git history.
58+
# More info on the properties API here: https://jfrog.com/help/r/jfrog-rest-apis/set-item-properties
59+
60+
# First publish the versioned file
61+
curl -H "Authorization:Bearer ${ARTIFACTORY_ACCESS_TOKEN}" -T "${targetFile}" "${publishUrl}"
62+
propertiesUrl="${apiBaseUrl}/${targetFile}?properties=version=${buildVersion};ci_commit_short_sha=${CI_COMMIT_SHORT_SHA}"
63+
curl -X PUT --fail -H "Authorization:Bearer ${ARTIFACTORY_ACCESS_TOKEN}" "${propertiesUrl}"
64+
65+
# Then create a latest version. BUT we don't want to do this on beta tags. A
66+
# pattern to adapt is to use `beta.` prefix on the tag when doing some testing.
67+
# In that scenario, we don't want to affect the latest version that gets published.
68+
if [[ ! "${CI_COMMIT_TAG}" =~ ^beta\..+ ]]
69+
then
70+
curl -H "Authorization:Bearer ${ARTIFACTORY_ACCESS_TOKEN}" -T "${targetFile}" "${publishUrlLatest}"
71+
propertiesUrlLatest="${apiBaseUrl}/sert_latest.zip?properties=version=${buildVersion};ci_commit_short_sha=${CI_COMMIT_SHORT_SHA}"
72+
curl -X PUT --fail -H "Authorization:Bearer ${ARTIFACTORY_ACCESS_TOKEN}" "${propertiesUrlLatest}"
73+
fi
74+
fi

development/scripts/reset.sql

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
set serveroutput on
2+
3+
declare
4+
procedure drop_user(p_user in varchar2)
5+
as
6+
e_user_not_found exception;
7+
pragma exception_init(e_user_not_found, -01918);
8+
begin
9+
dbms_output.put_line('dropping user '||p_user);
10+
execute immediate 'drop user ' || p_user || ' cascade';
11+
-- if user doesnt exist, just continue without error
12+
exception when e_user_not_found then null;
13+
end drop_user;
14+
15+
--
16+
17+
procedure clear_lb_table(p_table in varchar2)
18+
as
19+
e_table_not_found exception;
20+
pragma exception_init(e_table_not_found, -00942);
21+
begin
22+
execute immediate 'truncate table acdc.' || p_table;
23+
-- if table doesnt exist, just continue without error
24+
exception when e_table_not_found then null;
25+
end clear_lb_table;
26+
27+
--
28+
29+
procedure remove_apex_workspace(p_workspace_name in varchar2)
30+
as
31+
e_workspace_not_found exception;
32+
pragma exception_init(e_workspace_not_found, -20987);
33+
begin
34+
35+
for rec in (select grantor_workspace workspace
36+
from apex_workspace_extension_grant
37+
where grantee_workspace = upper('SERT' )
38+
) loop
39+
apex_instance_admin.revoke_extension_workspace(p_from_workspace => rec.workspace,p_to_workspace => 'SERT');
40+
end loop;
41+
apex_extension.remove_menu_entry(p_label => 'APEX SERT', p_workspace => 'SERT');
42+
commit;
43+
--
44+
apex_instance_admin.remove_workspace(p_workspace_name);
45+
-- if workspace doesnt exist, just continue without error
46+
-- apex_extension.remove_menu_entry(p_label => 'APEX SERT', p_workspace => 'SERT');
47+
exception when e_workspace_not_found then null;
48+
end remove_apex_workspace;
49+
begin
50+
51+
dbms_output.put_line('Clear changelog tables');
52+
clear_lb_table(p_table => 'SERT_DATABASECHANGELOG');
53+
clear_lb_table(p_table => 'SERT_DATABASECHANGELOG_ACTIONS');
54+
clear_lb_table(p_table => 'SERT_DATABASECHANGELOGLOCK');
55+
56+
dbms_output.put_line('Drop APEX workspace');
57+
remove_apex_workspace('SERT');
58+
-- commit;
59+
dbms_output.put_line('Drop sert schemas');
60+
drop_user('sert_core');
61+
drop_user('sert_pub');
62+
end;
63+
/

development/seed_scripts/.DS_Store

6 KB
Binary file not shown.

0 commit comments

Comments
 (0)