Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LR-588 checking PII fields with respect to security levels #50

Merged
merged 107 commits into from
Jun 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
107 commits
Select commit Hold shift + click to select a range
a6f39ae
LR-546 PII code implementation for data-products
Hari-stackroute May 5, 2023
d5231e7
Merge remote-tracking branch 'upstream/release-5.3.0' into LR-546
Hari-stackroute May 5, 2023
43aa464
LR-546 code changes for PII in reports
Hari-stackroute May 6, 2023
e10bf7f
LR-546 code changes for PII in reports
Hari-stackroute May 8, 2023
59bf476
LR-546 removed pom changes
Hari-stackroute May 8, 2023
0a88c78
LR-546 removed unnecessary test file changes
Hari-stackroute May 8, 2023
d36c914
LR-546 removed duplicate code
Hari-stackroute May 8, 2023
8accd97
LR-546 tested zip functionality
Hari-stackroute May 8, 2023
cafd0b6
LR-546 removed token details from conf
Hari-stackroute May 9, 2023
5f28dfd
LR-546 added test cases
Hari-stackroute May 10, 2023
c0dcb4b
LR-546 removed access-token from request
Hari-stackroute May 11, 2023
60d804d
LR-546 removed unused methods from HttpUtil
Hari-stackroute May 11, 2023
c686cfb
Merge remote-tracking branch 'upstream/release-5.3.0' into LR-546
Hari-stackroute May 12, 2023
212cae2
LR-546 code changes against review points
Hari-stackroute May 13, 2023
48d3faf
LR-546 code changes against review points
Hari-stackroute May 15, 2023
cb93e78
LR-546 code changes against review points
Hari-stackroute May 15, 2023
ee9f682
LR-546 code changes against review points
Hari-stackroute May 15, 2023
3adf311
LR-546 test-case fix
Hari-stackroute May 15, 2023
ebcc36f
LR-546 test-case fix-1
Hari-stackroute May 15, 2023
31b4951
LR-546 test-case fix-2
Hari-stackroute May 15, 2023
92b54eb
LR-546 code fixes for PII changes
Hari-stackroute May 16, 2023
49ce24d
LR-546 code fixes for PII changes-1
Hari-stackroute May 16, 2023
942dce4
LR-546 code fixes for PII changes-2
Hari-stackroute May 16, 2023
aec99b0
LR-546 level codes changed
Hari-stackroute May 16, 2023
aef04d0
LR-546 removed level and orgid details from JobRequest
Hari-stackroute May 16, 2023
9ee8739
LR-546 removed level and orgid details from JobRequest-1
Hari-stackroute May 16, 2023
fdbb791
LR-546 ignoring test-cases
Hari-stackroute May 16, 2023
b789597
LR-546 modified Encrypt util
Hari-stackroute May 17, 2023
0954e49
LR-546 expection with tenant preferance endpoint configuration
Hari-stackroute May 17, 2023
c1c50bf
LR-546 expection with tenant preferance endpoint configuration-1
Hari-stackroute May 17, 2023
e07afeb
LR-546 expection with tenant preferance endpoint configuration-2
Hari-stackroute May 17, 2023
8ee1d96
LR-546 expection with tenant preferance endpoint configuration-3
Hari-stackroute May 17, 2023
fcdbef1
LR-546 dev env configuration changes for spark
Hari-stackroute May 18, 2023
f0bd47a
LR-546 added logs
Hari-stackroute May 18, 2023
b3d08bb
LR-546 added logs-1
Hari-stackroute May 18, 2023
71fd18e
LR-546 added logs-2
Hari-stackroute May 18, 2023
a01d01b
LR-546 added logs-3
Hari-stackroute May 18, 2023
31f15d2
LR-546 added logs-4
Hari-stackroute May 18, 2023
6108409
LR-546 added logs-5
Hari-stackroute May 18, 2023
f4ab3c2
LR-546 added logs-6
Hari-stackroute May 18, 2023
ab105b5
LR-546 added logs-7
Hari-stackroute May 18, 2023
cdd503c
LR-546 added logs-8
Hari-stackroute May 18, 2023
6feefe6
LR-546 L3 level eccryption throwing errors
Hari-stackroute May 19, 2023
8735fec
LR-546 L3 level eccryption throwing errors-1
Hari-stackroute May 19, 2023
ce2357a
LR-546 L3 level eccryption throwing errors-2
Hari-stackroute May 19, 2023
d09d5a1
LR-546 config changes
Hari-stackroute May 19, 2023
2905ddf
LR-546 commented test-cases
Hari-stackroute May 21, 2023
865efe9
Delete BaseCollectionExhaustJob1.scala
Hari-stackroute May 21, 2023
c416c1a
LR-546 ignored test-cases
Hari-stackroute May 21, 2023
73dd8ca
Merge branch 'LR-546' of https://github.com/Hari-stackroute/data-prod…
Hari-stackroute May 21, 2023
bc801ab
LR-546 ignored test-cases-1
Hari-stackroute May 21, 2023
beaca03
LR-546 ignored test-cases-2
Hari-stackroute May 21, 2023
b380282
LR-546 ignored test-cases-2
Hari-stackroute May 21, 2023
0516264
LR-546 ignored test-cases-3
Hari-stackroute May 21, 2023
e87750c
LR-546 ignored test-cases-4
Hari-stackroute May 21, 2023
8fae531
Merge remote-tracking branch 'upstream/release-5.3.0' into LR-546
Hari-stackroute May 22, 2023
f6cbb12
LR-546 added new line between ecrypted text and file content
Hari-stackroute May 22, 2023
cc02b5a
LR-546 L4 level changes
Hari-stackroute May 23, 2023
07ee5e8
LR-546 L4 level changes-1
Hari-stackroute May 23, 2023
f4a61ec
LR-546 L4 level changes-2
Hari-stackroute May 23, 2023
875fd2a
LR-546 L3 level changes
Hari-stackroute May 25, 2023
a930400
LR-546 L3 level changes-1
Hari-stackroute May 25, 2023
5a16587
Merge remote-tracking branch 'upstream/release-5.3.0' into LR-546
Hari-stackroute May 25, 2023
aab3eb5
LR-546 L3 level fixing encrypted text to 32bytes
Hari-stackroute May 25, 2023
3c31256
LR-546 L3 level fixing encrypted text to 32bytes-1
Hari-stackroute May 25, 2023
0ac7465
LR-546 L3 level fixing encrypted text to 32bytes-2
Hari-stackroute May 25, 2023
2737bdc
LR-546 zip generation in L1
Hari-stackroute May 29, 2023
afac4b9
Merge remote-tracking branch 'upstream/release-5.3.0' into LR-546
Hari-stackroute May 29, 2023
da1b3a2
LR-546 zip generation in L1-1
Hari-stackroute May 29, 2023
b25f0c1
LR-588 checking PII fields with respect to security levels
Hari-stackroute Jun 9, 2023
08db7a9
LR-588 improving test--cases
Hari-stackroute Jun 14, 2023
252f66c
LR-588 improving test-cases-1
Hari-stackroute Jun 15, 2023
8dcc1bb
LR-588 improving test-cases-2
Hari-stackroute Jun 15, 2023
8f024c9
LR-588 improving test-cases-3
Hari-stackroute Jun 15, 2023
68608c1
LR-588 improving test-cases-4
Hari-stackroute Jun 15, 2023
345cf0f
LR-588 improving test-cases-5
Hari-stackroute Jun 15, 2023
0b813f0
LR-588 added missing property
Hari-stackroute Jun 15, 2023
54f60da
Added missed change
Hari-stackroute Jun 15, 2023
eefb5b3
Test-case related
Hari-stackroute Jun 16, 2023
5fbee34
Test-case related-1
Hari-stackroute Jun 16, 2023
1b48f4c
Test-case related-2
Hari-stackroute Jun 16, 2023
546be50
Test-case related-3
Hari-stackroute Jun 17, 2023
a3bbdbd
fixing test-cases
Hari-stackroute Jun 19, 2023
640d8bf
fixing test-cases-1
Hari-stackroute Jun 19, 2023
c066773
fixing test-cases-2
Hari-stackroute Jun 19, 2023
2f8bb7e
fixing test-cases-3
Hari-stackroute Jun 19, 2023
9d8e9f8
fixing test-cases-4
Hari-stackroute Jun 20, 2023
d4ece15
fixing test-cases-5
Hari-stackroute Jun 20, 2023
8225873
fixing test-cases-6
Hari-stackroute Jun 20, 2023
4911970
fixing test-cases-7
Hari-stackroute Jun 22, 2023
2631ece
LR-588 | testcase fixes added
kumarks1122 Jun 22, 2023
ff463e0
LR-588 | testcase fixes added
kumarks1122 Jun 22, 2023
eb2f0aa
Update pom.xml
Hari-stackroute Jun 22, 2023
4885b78
Merge branch 'release-5.3.0' into LR-588
Hari-stackroute Jun 22, 2023
f83bbab
LR-588 undo pom changes-1
Hari-stackroute Jun 22, 2023
207d994
LR-588 | testcase fixes added
kumarks1122 Jun 23, 2023
5b07472
Merge branch 'LR-588' of github.com:Hari-stackroute/data-products int…
kumarks1122 Jun 23, 2023
0bd1970
LR-588 | testcase fixes added
kumarks1122 Jun 23, 2023
c2e7e2e
LR-588 | testcase fixes added
kumarks1122 Jun 23, 2023
bc0c27a
LR-588 exception resolved for P
Hari-stackroute Jun 26, 2023
5badf22
LR-588 exception resolved for P
Hari-stackroute Jun 26, 2023
7c79936
LR-588 exception resolved for P
Hari-stackroute Jun 26, 2023
fbdf3df
LR-588 exception resolved for P
Hari-stackroute Jun 26, 2023
f3f6b82
LR-588 | testcase fixes added
kumarks1122 Jun 26, 2023
34f8939
LR-588 exception resolved for P
Hari-stackroute Jun 26, 2023
fe444f7
LR-588 | reverting 5.4 changes
kumarks1122 Jun 27, 2023
ad1f811
Merge branch 'LR-588' of github.com:Hari-stackroute/data-products int…
kumarks1122 Jun 27, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,16 @@ config() {
echo '{"search":{"type":"none"},"model":"org.sunbird.lms.audit.CollectionSummaryJobV2","modelParams":{"storageKeyConfig":"druid_storage_account_key","storageSecretConfig":"druid_storage_account_secret","batchSize":50,"generateForAllBatches":true,"contentFields":["identifier","name","organisation","channel","status","keywords","createdFor","medium","subject"],"contentStatus":["Live","Unlisted","Retired"],"store":"azure","specPath":"/mount/data/analytics/scripts/collection-summary-ingestion-spec.json","druidIngestionUrl":"'$druidIngestionURL'","sparkElasticsearchConnectionHost":"{{ sunbird_es_host }}","sparkRedisConnectionHost":"{{ metadata2_redis_host }}","sparkUserDbRedisIndex":"12","sparkUserDbRedisPort":"{{ user_port }}","sparkCassandraConnectionHost":"{{ core_cassandra_host }}","fromDate":"$(date --date yesterday '+%Y-%m-%d')","toDate":"$(date --date yesterday '+%Y-%m-%d')"},"parallelization":8,"appName":"Collection Summary Report V2"}'
;;
"userinfo-exhaust")
echo '{"search":{"type":"none"},"model":"org.sunbird.lms.exhaust.collection.UserInfoExhaustJob","modelParams":{"store":"azure","mode":"OnDemand","batchFilters":["TPD"],"searchFilter":{}, "sparkElasticsearchConnectionHost":"{{ sunbird_es_host }}","sparkRedisConnectionHost":"{{ metadata2_redis_host }}","sparkUserDbRedisIndex":"12","sparkUserDbRedisPort":"{{ user_port }}", "sparkCassandraConnectionHost":"{{ core_cassandra_host }}", "fromDate":"$(date --date yesterday '+%Y-%m-%d')","toDate":"$(date --date yesterday '+%Y-%m-%d')"},"parallelization":8,"appName":"UserInfo Exhaust"}'
echo '{"search":{"type":"none"},"model":"org.sunbird.lms.exhaust.collection.UserInfoExhaustJob","modelParams":{"store":"azure","mode":"OnDemand","batchFilters":["TPD"],"searchFilter":{}, "sparkElasticsearchConnectionHost":"{{ sunbird_es_host }}","sparkRedisConnectionHost":"{{ metadata2_redis_host }}","sparkUserDbRedisIndex":"12","sparkUserDbRedisPort":"{{ user_port }}", "sparkCassandraConnectionHost":"{{ core_cassandra_host }}", "fromDate":"$(date --date yesterday '+%Y-%m-%d')","toDate":"$(date --date yesterday '+%Y-%m-%d')","csvColumns":["courseid", "collectionName", "batchid", "batchName", "userid", "username", "state", "district", "orgname", "email", "phone","consentflag", "consentprovideddate", "block", "cluster", "usertype", "usersubtype", "schooludisecode", "schoolname"]},"parallelization":8,"appName":"UserInfo Exhaust"}'
;;
"response-exhaust")
echo '{"search":{"type":"none"},"model":"org.sunbird.lms.exhaust.collection.ResponseExhaustJob","modelParams":{"store":"azure","mode":"OnDemand","batchFilters":["TPD"],"searchFilter":{}, "sparkElasticsearchConnectionHost":"{{ sunbird_es_host }}","sparkRedisConnectionHost":"{{ metadata2_redis_host }}","sparkUserDbRedisIndex":"12","sparkUserDbRedisPort":"{{ user_port }}", "sparkCassandraConnectionHost":"{{ core_cassandra_host }}", "fromDate":"$(date --date yesterday '+%Y-%m-%d')","toDate":"$(date --date yesterday '+%Y-%m-%d')"},"parallelization":8,"appName":"Response Exhaust"}'
echo '{"search":{"type":"none"},"model":"org.sunbird.lms.exhaust.collection.ResponseExhaustJob","modelParams":{"store":"azure","mode":"OnDemand","batchFilters":["TPD"],"searchFilter":{}, "sparkElasticsearchConnectionHost":"{{ sunbird_es_host }}","sparkRedisConnectionHost":"{{ metadata2_redis_host }}","sparkUserDbRedisIndex":"12","sparkUserDbRedisPort":"{{ user_port }}", "sparkCassandraConnectionHost":"{{ core_cassandra_host }}", "fromDate":"$(date --date yesterday '+%Y-%m-%d')","toDate":"$(date --date yesterday '+%Y-%m-%d')","csvColumns":["courseid", "collectionName", "batchid", "batchName", "userid", "content_id", "contentname", "attempt_id", "last_attempted_on", "questionid","questiontype", "questiontitle", "questiondescription", "questionduration", "questionscore", "questionmaxscore", "questionoption", "questionresponse"]},"parallelization":8,"appName":"Response Exhaust"}'
;;
"response-exhaust-v2")
echo '{"search":{"type":"none"},"model":"org.sunbird.lms.exhaust.collection.ResponseExhaustJobV2","modelParams":{"store":"azure","mode":"OnDemand","batchFilters":["TPD"],"searchFilter":{}, "sparkElasticsearchConnectionHost":"{{ sunbird_es_host }}","sparkRedisConnectionHost":"{{ metadata2_redis_host }}","sparkUserDbRedisIndex":"12","sparkUserDbRedisPort":"{{ user_port }}", "sparkCassandraConnectionHost":"{{ core_cassandra_host }}", "fromDate":"$(date --date yesterday '+%Y-%m-%d')","toDate":"$(date --date yesterday '+%Y-%m-%d')"},"parallelization":8,"appName":"Response Exhaust V2"}'
echo '{"search":{"type":"none"},"model":"org.sunbird.lms.exhaust.collection.ResponseExhaustJobV2","modelParams":{"store":"azure","mode":"OnDemand","batchFilters":["TPD"],"searchFilter":{}, "sparkElasticsearchConnectionHost":"{{ sunbird_es_host }}","sparkRedisConnectionHost":"{{ metadata2_redis_host }}","sparkUserDbRedisIndex":"12","sparkUserDbRedisPort":"{{ user_port }}", "sparkCassandraConnectionHost":"{{ core_cassandra_host }}", "fromDate":"$(date --date yesterday '+%Y-%m-%d')","toDate":"$(date --date yesterday '+%Y-%m-%d')","csvColumns":["courseid", "collectionName", "batchid", "batchName", "userid", "content_id", "contentname", "attempt_id", "last_attempted_on", "questionid", "questiontype", "questiontitle", "questiondescription", "questionduration", "questionscore", "questionmaxscore", "questionoption", "questionresponse"]},"parallelization":8,"appName":"Response Exhaust V2"}'
;;
"progress-exhaust")
echo '{"search":{"type":"none"},"model":"org.sunbird.lms.exhaust.collection.ProgressExhaustJob","modelParams":{"store":"azure","mode":"OnDemand","batchFilters":["TPD"],"searchFilter":{}, "sparkElasticsearchConnectionHost":"{{ sunbird_es_host }}","sparkRedisConnectionHost":"{{ metadata2_redis_host }}","sparkUserDbRedisIndex":"12","sparkUserDbRedisPort":"{{ user_port }}", "sparkCassandraConnectionHost":"{{ core_cassandra_host }}", "fromDate":"$(date --date yesterday '+%Y-%m-%d')","toDate":"$(date --date yesterday '+%Y-%m-%d')"},"parallelization":8,"appName":"Progress Exhaust"}'
echo '{"search":{"type":"none"},"model":"org.sunbird.lms.exhaust.collection.ProgressExhaustJob","modelParams":{"store":"azure","mode":"OnDemand","batchFilters":["TPD"],"searchFilter":{}, "sparkElasticsearchConnectionHost":"{{ sunbird_es_host }}","sparkRedisConnectionHost":"{{ metadata2_redis_host }}","sparkUserDbRedisIndex":"12","sparkUserDbRedisPort":"{{ user_port }}", "sparkCassandraConnectionHost":"{{ core_cassandra_host }}", "fromDate":"$(date --date yesterday '+%Y-%m-%d')","toDate":"$(date --date yesterday '+%Y-%m-%d')","csvColumns":["courseid", "collectionName", "batchid", "batchName", "userid", "state", "district", "orgname", "schooludisecode", "schoolname", "board", "block", "cluster", "usertype", "usersubtype", "enrolleddate", "completedon", "certificatestatus", "completionPercentage"]},"parallelization":8,"appName":"Progress Exhaust"}'
;;
"progress-exhaust-v2")
echo '{"search":{"type":"none"},"model":"org.sunbird.lms.exhaust.collection.ProgressExhaustJobV2","modelParams":{"store":"azure","mode":"OnDemand","batchFilters":["TPD"],"searchFilter":{}, "sparkElasticsearchConnectionHost":"{{ sunbird_es_host }}","sparkRedisConnectionHost":"{{ metadata2_redis_host }}","sparkUserDbRedisIndex":"12","sparkUserDbRedisPort":"{{ user_port }}", "sparkCassandraConnectionHost":"{{ core_cassandra_host }}", "fromDate":"$(date --date yesterday '+%Y-%m-%d')","toDate":"$(date --date yesterday '+%Y-%m-%d')"},"parallelization":8,"appName":"Progress Exhaust V2"}'
Expand Down
2 changes: 1 addition & 1 deletion lern-data-products/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -500,4 +500,4 @@
</plugin>
</plugins>
</build>
</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,6 @@ trait BaseReportsJob {
StorageConfig(store, container, key, Option(storageKey), Option(storageSecret));
}

def validateCsvColumns(piiFields: List[String], csvColumns: List[String], level: String): Boolean = true

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,55 @@ object DataSecurityUtil {
*/
def getSecurityLevel(jobId: String, orgId: String): String = {
JobLogger.log(s"getSecurityLevel jobID:: $jobId orgid:: $orgId", None, INFO)(new String())
val requestBody = Map("request" -> Map("orgId" -> orgId, "key" -> "dataSecurityPolicy"))
val httpResponseBody = getTenantPreferanceDetails(orgId, "dataSecurityPolicy")
val responseBody = JSONUtils.deserialize[Map[String, AnyRef]](httpResponseBody)
val data = responseBody.getOrElse("result", Map[String, AnyRef]()).asInstanceOf[Map[String, AnyRef]]
.getOrElse("response", Map[String, AnyRef]()).asInstanceOf[Map[String, AnyRef]]
.getOrElse("data", Map[String, AnyRef]()).asInstanceOf[Map[String, AnyRef]]
val globalLevel = data.getOrElse("level", "").asInstanceOf[String]
val jobDetail = data.getOrElse("job", Map[String, AnyRef]()).asInstanceOf[Map[String, AnyRef]]
.getOrElse(jobId, Map[String, AnyRef]()).asInstanceOf[Map[String, AnyRef]]
val jobLevel = jobDetail.getOrElse("level", "").asInstanceOf[String]
if (!StringUtils.isEmpty(jobLevel)) jobLevel else globalLevel
}

/**
* fetch the PII fields by calling tenant preference read API using orgId
*
* @param jobId
* @param orgId
* @return
*/
def getPIIFieldDetails(jobId: String, orgId: String): List[String] = {
JobLogger.log(s"getSecurityLevel jobID:: $jobId orgid:: $orgId", None, INFO)(new String())
val httpResponseBody = getTenantPreferanceDetails(orgId, "userPrivateFields")
val responseBody = JSONUtils.deserialize[Map[String, AnyRef]](httpResponseBody)
val data = responseBody.getOrElse("result", Map[String, AnyRef]()).asInstanceOf[Map[String, AnyRef]]
.getOrElse("response", Map[String, AnyRef]()).asInstanceOf[Map[String, AnyRef]]
.getOrElse("data", Map[String, AnyRef]()).asInstanceOf[Map[String, AnyRef]]
val piiFields = data.getOrElse("piiFields", List[String]()).asInstanceOf[List[String]]
piiFields
}

/**
* fetch the job security level by calling tenant preference read API using orgId
*
* @param jobId
* @param orgId
* @return
*/
def getTenantPreferanceDetails(orgId: String, key: String): String = {
JobLogger.log(s"getTenantPreferanceDetails orgid:: $orgId", None, INFO)(new String())
val requestBody = Map("request" -> Map("orgId" -> orgId, "key" -> key))
val request = JSONUtils.serialize(requestBody)
val headers: Map[String, String] = Map("Content-Type" -> "application/json")
val readTenantPrefURL = Constants.TENANT_PREFERENCE_PRIVATE_READ_URL
JobLogger.log(s"getSecurityLevel readTenantPrefURL:: $readTenantPrefURL", None, INFO)(new String())
JobLogger.log(s"getTenantPreferanceDetails readTenantPrefURL:: $readTenantPrefURL", None, INFO)(new String())
val httpResponse = httpUtil.post(readTenantPrefURL, request, headers)
if (httpResponse.status == 200) {
JobLogger.log(s"dataSecurityPolicy for org=$orgId, response body=${httpResponse.body}", None, INFO)(new String())
val responseBody = JSONUtils.deserialize[Map[String, AnyRef]](httpResponse.body)
val data = responseBody.getOrElse("result", Map[String, AnyRef]()).asInstanceOf[Map[String, AnyRef]]
.getOrElse("response", Map[String, AnyRef]()).asInstanceOf[Map[String, AnyRef]]
.getOrElse("data", Map[String, AnyRef]()).asInstanceOf[Map[String, AnyRef]]
val globalLevel = data.getOrElse("level", "").asInstanceOf[String]
val jobDetail = data.getOrElse("job", Map[String, AnyRef]()).asInstanceOf[Map[String, AnyRef]]
.getOrElse(jobId, Map[String, AnyRef]()).asInstanceOf[Map[String, AnyRef]]
val jobLevel = jobDetail.getOrElse("level", "").asInstanceOf[String]
if (!StringUtils.isEmpty(jobLevel)) jobLevel else globalLevel
JobLogger.log(s"getTenantPreferanceDetails for org=$orgId, response body=${httpResponse.body}", None, INFO)(new String())
val responseBody = httpResponse.body
responseBody
} else {
JobLogger.log(s"Error response from Tenant Preferance read API for request :: $requestBody :: response is :: ${httpResponse.status} :: ${httpResponse.body}", None, ERROR)(new String())
""
Expand Down Expand Up @@ -169,6 +201,7 @@ object DataSecurityUtil {
var tempDir = ""
if (level.nonEmpty) {
val storageService = fc.getStorageService(storageConfig.store, storageConfig.accountKey.getOrElse(""), storageConfig.secretKey.getOrElse(""));
val path = Paths.get(url)
val filePrefix = storageConfig.store.toLowerCase() match {
// $COVERAGE-OFF$ Disabling scoverage
case "s3" =>
Expand All @@ -179,19 +212,26 @@ object DataSecurityUtil {
CommonUtil.getGCloudFile(storageConfig.container, "")
// $COVERAGE-ON$ for case: local
case _ =>
storageConfig.fileName
val filePath = path.toString
if (filePath.contains(storageConfig.fileName)){
filePath
} else {
storageConfig.fileName + "/" + filePath
}

}

if (!url.isEmpty ) {
if(request != null) {
tempDir = AppConf.getConfig("spark_output_temp_dir") + request.request_id + "/"
} else {
val urlSplitArr = url.split("/")
if (!storageConfig.store.equals("local")) {
val urlSplitArr = url.split("/")
tempDir = AppConf.getConfig("spark_output_temp_dir") + urlSplitArr(3) + "/"
} else {
tempDir = AppConf.getConfig("spark_output_temp_dir") + urlSplitArr(4) + "/"
}
}
val path = Paths.get(url)
objKey = url.replace(filePrefix, "")
localPath = tempDir + path.getFileName
fc.getHadoopFileUtil().delete(conf, tempDir)
Expand Down Expand Up @@ -237,9 +277,11 @@ object DataSecurityUtil {
if(request != null) {
tempDir = AppConf.getConfig("spark_output_temp_dir") + request.request_id + "/"
} else {
val urlSplitArr = url.split("/")
if (!storageConfig.store.equals("local")) {
val urlSplitArr = url.split("/")
tempDir = AppConf.getConfig("spark_output_temp_dir") + urlSplitArr(3) + "/"
} else {
tempDir = AppConf.getConfig("spark_output_temp_dir") + urlSplitArr(4) + "/"
}
}
val path = Paths.get(url)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import org.joda.time.format.{DateTimeFormat, DateTimeFormatter}
import org.joda.time.{DateTime, DateTimeZone}
import org.sunbird.core.util.{DecryptUtil, RedisConnect}
import org.sunbird.core.exhaust.{BaseReportsJob, JobRequest, OnDemandExhaustJob}
import org.sunbird.core.util.DataSecurityUtil.{getOrgId, getSecuredExhaustFile, getSecurityLevel}
import org.sunbird.core.util.DataSecurityUtil.{getOrgId, getPIIFieldDetails, getSecuredExhaustFile, getSecurityLevel}
import org.sunbird.lms.exhaust.collection.ResponseExhaustJobV2.Question

import java.security.MessageDigest
Expand Down Expand Up @@ -151,6 +151,8 @@ trait BaseCollectionExhaustJob extends BaseReportsJob with IJob with OnDemandExh
JobLogger.log(s"executeOnDemand for channel= "+ request.requested_channel, None, INFO)
val orgId = request.requested_channel//getOrgId("", request.requested_channel)
val level = getSecurityLevel(jobId(), orgId)
val piiFields = getPIIFieldDetails(jobId(), orgId)
val csvColumns = modelParams.getOrElse("csvColumns", List[String]()).asInstanceOf[List[String]]
JobLogger.log(s"executeOnDemand for url = $orgId and level = $level and channel= $request.requested_channel", None, INFO)
val reqOrgAndLevel = (request.request_id, orgId, level)
reqOrgAndLevelDtl :+= reqOrgAndLevel
Expand All @@ -161,6 +163,10 @@ trait BaseCollectionExhaustJob extends BaseReportsJob with IJob with OnDemandExh
JobLogger.log("Channel details at executeOnDemand", Some(Map("channel" -> request.requested_channel, "file size" -> processedSize, "completed batches" -> processedCount)), INFO)

if (checkRequestProcessCriteria(processedCount, processedSize)) {
if(!validateCsvColumns(piiFields, csvColumns, level)) {
JobLogger.log("Request should have either of batchId, batchFilter, searchFilter or encrption key", Some(Map("requestId" -> request.request_id, "remainingRequest" -> totalRequests.getAndDecrement())), INFO)
markRequestAsFailed(request, "Request Security Level is not matching with PII fields or csvColumns CSV columns configured. Please check.")
}
if (validateRequest(request)) {
val res = processRequest(request, custodianOrgId, userCachedDF, storageConfig, requestsCompleted, orgId, level)
requestsCompleted.++=(JSONUtils.deserialize[ListBuffer[ProcessedRequest]](res.processed_batches.getOrElse("[]")))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import org.apache.spark.sql.expressions.Window
import org.apache.spark.sql.functions._
import org.apache.spark.sql.types.StructType
import org.apache.spark.sql.{DataFrame, SparkSession}
import org.ekstep.analytics.framework.Level.INFO
import org.ekstep.analytics.framework.conf.AppConf
import org.ekstep.analytics.framework.util.JSONUtils
import org.ekstep.analytics.framework.util.{JSONUtils, JobLogger}
import org.ekstep.analytics.framework.{FrameworkContext, JobConfig}

import scala.collection.immutable.Set
Expand Down Expand Up @@ -42,8 +43,7 @@ object ProgressExhaustJob extends BaseCollectionExhaustJob {
private val activityAggDBSettings = Map("table" -> "user_activity_agg", "keyspace" -> AppConf.getConfig("sunbird.courses.keyspace"), "cluster" -> "LMSCluster");
private val assessmentAggDBSettings = Map("table" -> "assessment_aggregator", "keyspace" -> AppConf.getConfig("sunbird.courses.keyspace"), "cluster" -> "LMSCluster");
private val contentHierarchyDBSettings = Map("table" -> "content_hierarchy", "keyspace" -> AppConf.getConfig("sunbird.content.hierarchy.keyspace"), "cluster" -> "ContentCluster");

private val filterColumns = Seq("courseid", "collectionName", "batchid", "batchName", "userid", "state", "district", "orgname", "schooludisecode", "schoolname", "board", "block", "cluster", "usertype", "usersubtype", "enrolleddate", "completedon", "certificatestatus", "completionPercentage");
//private val filterColumns = Seq("courseid", "collectionName", "batchid", "batchName", "userid", "state", "district", "orgname", "schooludisecode", "schoolname", "board", "block", "cluster", "usertype", "usersubtype", "enrolleddate", "completedon", "certificatestatus", "completionPercentage");
private val columnsOrder = List("Collection Id", "Collection Name", "Batch Id", "Batch Name", "User UUID", "State", "District", "Org Name", "School Id",
"School Name", "Block Name", "Cluster Name", "User Type", "User Sub Type", "Declared Board", "Enrolment Date", "Completion Date", "Certificate Status", "Progress", "Total Score")
private val columnMapping = Map("courseid" -> "Collection Id", "collectionName" -> "Collection Name", "batchid" -> "Batch Id", "batchName" -> "Batch Name", "userid" -> "User UUID",
Expand All @@ -52,6 +52,7 @@ object ProgressExhaustJob extends BaseCollectionExhaustJob {
"completionPercentage" -> "Progress", "total_sum_score" -> "Total Score", "certificatestatus" -> "Certificate Status")

override def processBatch(userEnrolmentDF: DataFrame, collectionBatch: CollectionBatch)(implicit spark: SparkSession, fc: FrameworkContext, config: JobConfig): DataFrame = {
val filterColumns : List[String] = config.modelParams.get.getOrElse("csvColumns", List[String]()).asInstanceOf[List[String]]
val hierarchyData = loadCollectionHierarchy(collectionBatch.collectionId)
//val collectionAggDF = getCollectionAggWithModuleData(collectionBatch, hierarchyData).withColumn("batchid", lit(collectionBatch.batchId));
//val enrolledUsersToBatch = updateCertificateStatus(userEnrolmentDF).select(filterColumns.head, filterColumns.tail: _*)
Expand Down
Loading