-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Transferring service and controller vulnerabilities to cosv (#2894)
* Transferring service and controller vulnerabilities to cosv
- Loading branch information
1 parent
0c1839d
commit 620a3ea
Showing
14 changed files
with
271 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
save-cosv/src/main/kotlin/com/saveourtool/save/cosv/repository/OrganizationRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.saveourtool.save.cosv.repository | ||
|
||
import com.saveourtool.save.entities.Organization | ||
import org.springframework.data.jpa.repository.Query | ||
import org.springframework.data.repository.query.Param | ||
import org.springframework.stereotype.Repository | ||
|
||
/** | ||
* The repository of organization entities | ||
*/ | ||
@Repository | ||
interface OrganizationRepository { | ||
/** | ||
* @param organizationName organization name for update | ||
* @param rating new organization rating | ||
* @return updated organization | ||
*/ | ||
@Query( | ||
value = "update save_cloud.organization o set o.rating = :rating where o.name = :organization_name", | ||
nativeQuery = true, | ||
) | ||
fun updateOrganization( | ||
@Param("organization_name") organizationName: String, | ||
@Param("rating") rating: Long, | ||
) | ||
|
||
/** | ||
* @param name name of organization | ||
* @return found [Organization] by name | ||
*/ | ||
@Query( | ||
value = "select * from save_cloud.organization where name = :name", | ||
nativeQuery = true, | ||
) | ||
fun getOrganizationByName(@Param("name") name: String): Organization | ||
} |
40 changes: 40 additions & 0 deletions
40
save-cosv/src/main/kotlin/com/saveourtool/save/cosv/repository/TagRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.saveourtool.save.cosv.repository | ||
|
||
import com.saveourtool.save.entities.Tag | ||
import org.springframework.data.jpa.repository.Modifying | ||
import org.springframework.data.jpa.repository.Query | ||
import org.springframework.data.repository.query.Param | ||
import org.springframework.stereotype.Repository | ||
import org.springframework.transaction.annotation.Transactional | ||
|
||
/** | ||
* The repository of tag entities. | ||
*/ | ||
@Repository | ||
interface TagRepository { | ||
/** | ||
* Find [Tag] by its [Tag.name] | ||
* | ||
* @param name tag name | ||
* @return [Tag] if found, null otherwise | ||
*/ | ||
@Query( | ||
value = "select * from save_cloud.tag t where t.name = :name", | ||
nativeQuery = true, | ||
) | ||
fun findByName(@Param("name") name: String): Tag? | ||
|
||
/** | ||
* @param name name of tag | ||
* @return save tag | ||
*/ | ||
@Transactional | ||
@Modifying | ||
@Query( | ||
value = "insert into save_cloud.tag (name) values (:name)", | ||
nativeQuery = true, | ||
) | ||
fun saveTag( | ||
@Param("name") name: String, | ||
) | ||
} |
36 changes: 36 additions & 0 deletions
36
save-cosv/src/main/kotlin/com/saveourtool/save/cosv/repository/UserRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.saveourtool.save.cosv.repository | ||
|
||
import com.saveourtool.save.entities.User | ||
import org.springframework.data.jpa.repository.Query | ||
import org.springframework.data.repository.query.Param | ||
import org.springframework.stereotype.Repository | ||
|
||
/** | ||
* Repository to access data about users | ||
*/ | ||
@Repository | ||
interface UserRepository { | ||
/** | ||
* @param userName user name for update | ||
* @param rating new user rating | ||
* @return updated user | ||
*/ | ||
@Query( | ||
value = "update save_cloud.user u set u.rating = :rating where u.name = :user_name", | ||
nativeQuery = true, | ||
) | ||
fun updateUser( | ||
@Param("user_name") userName: String, | ||
@Param("rating") rating: Long, | ||
) | ||
|
||
/** | ||
* @param name name of organization | ||
* @return found [User] by name | ||
*/ | ||
@Query( | ||
value = "select * from save_cloud.user where name = :name", | ||
nativeQuery = true, | ||
) | ||
fun getUserByName(@Param("name") name: String): User | ||
} |
6 changes: 3 additions & 3 deletions
6
...urity/VulnerabilityPermissionEvaluator.kt → ...urity/VulnerabilityPermissionEvaluator.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
save-cosv/src/main/kotlin/com/saveourtool/save/cosv/service/OrganizationService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.saveourtool.save.cosv.service | ||
|
||
import com.saveourtool.save.cosv.repository.OrganizationRepository | ||
import com.saveourtool.save.entities.Organization | ||
|
||
/** | ||
* Service for organization | ||
*/ | ||
class OrganizationService( | ||
private val organizationRepository: OrganizationRepository, | ||
) { | ||
/** | ||
* @param organization organization for update | ||
* @return updated organization | ||
*/ | ||
fun saveUser(organization: Organization) = organizationRepository.updateOrganization(organization.name, organization.rating) | ||
|
||
/** | ||
* @param name | ||
* @return organization with [name] | ||
*/ | ||
fun getOrganizationByName(name: String): Organization = organizationRepository.getOrganizationByName(name) | ||
} |
22 changes: 22 additions & 0 deletions
22
save-cosv/src/main/kotlin/com/saveourtool/save/cosv/service/TagService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.saveourtool.save.cosv.service | ||
|
||
import com.saveourtool.save.cosv.repository.TagRepository | ||
import com.saveourtool.save.entities.Tag | ||
|
||
/** | ||
* Service for tag | ||
*/ | ||
class TagService( | ||
private val tagRepository: TagRepository, | ||
) { | ||
/** | ||
* @param name name of tag | ||
*/ | ||
fun saveTag(name: String) = tagRepository.saveTag(name) | ||
|
||
/** | ||
* @param name | ||
* @return tag with [name] | ||
*/ | ||
fun findTagByName(name: String): Tag? = tagRepository.findByName(name) | ||
} |
23 changes: 23 additions & 0 deletions
23
save-cosv/src/main/kotlin/com/saveourtool/save/cosv/service/UserService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.saveourtool.save.cosv.service | ||
|
||
import com.saveourtool.save.cosv.repository.UserRepository | ||
import com.saveourtool.save.entities.User | ||
|
||
/** | ||
* Service for user | ||
*/ | ||
class UserService( | ||
private val userRepository: UserRepository, | ||
) { | ||
/** | ||
* @param user user for update | ||
* @return updated user | ||
*/ | ||
fun saveUser(user: User) = userRepository.updateUser(user.name, user.rating) | ||
|
||
/** | ||
* @param name | ||
* @return user with [name] | ||
*/ | ||
fun getUserByName(name: String): User = userRepository.getUserByName(name) | ||
} |
Oops, something went wrong.