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

SECURITY-3: Switch from Ant -> Gradle #419

Merged
merged 12 commits into from
Feb 14, 2024
Merged

Conversation

MrCreosote
Copy link
Member

This PR is a bit large but for me it was easier to understand the changes with the full ant -> gradle conversion. Instead, the PR is split up mostly by commit - the first commit gets the basics (compile & test) working, and then each new commit adds a new feature (or in the case of the last commit, improves an old one).

I found that Eclipse Buildship really doesn't like our project layout, and so the next PR will switch the project to a standard Gradle layout, but that involves moving every single source file, so... different PR.

Comment on lines +108 to +109
// For some reason the test directories are included in the war file
// although the files are gone. Not sure why
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This gets fixed in the next PR

Copy link

codecov bot commented Feb 10, 2024

Codecov Report

Merging #419 (8fce168) into develop (09b2011) will not change coverage.
Report is 1 commits behind head on develop.
The diff coverage is n/a.

Additional details and impacted files
@@            Coverage Diff             @@
##             develop     #419   +/-   ##
==========================================
  Coverage      93.39%   93.39%           
  Complexity      2142     2142           
==========================================
  Files            126      126           
  Lines           7520     7520           
  Branches        1178     1178           
==========================================
  Hits            7023     7023           
  Misses           454      454           
  Partials          43       43           

task buildGitCommitFile {
doLast {
def commitId = grgit.head().id
// is there a varible for builddir/classe/java/main?
Copy link

@ialarmedalien ialarmedalien Feb 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typos

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have these fixed locally, they'll show up in a future PR if that's ok

Comment on lines +44 to +47
* TODO TEST Figure out why tests fail without this and remove. Might have something to do
* with the stfuLoggers() call in many of the tests, might kill logging for tests that
* require it
* Although it seems to make Mongo start up correctly as well which is odd

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same issue in the workspace -- there seems to be some sort of interaction between gradle and the loggers that means tests only pass with forkEvery on

// anyway.
// https://mvnrepository.com/artifact/org.jetbrains/syslog4j/0.9.46
// Need to rework the java common logger to not use syslog4j at all since it's abandonware
// and has a ton of CVEs, even in the newer versions.
Copy link

@ialarmedalien ialarmedalien Feb 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can get it easily by adding clojars to the repo list:

repositories {
 	mavenCentral()
	maven {
 		name = "Clojars"
 		url = "https://repo.clojars.org/"
 	}
 }

see https://github.com/kbase/workspace_deluxe/pull/676/files#diff-49a96e7eea8a94af862798a45174e6ac43eb4f8b4bd40759b5da63ba31ec3ef7

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, cool. That being said, I think there's a reason it's not on maven - it hasn't been maintained for 10 years and is riddled with CVEs. At this point I'd prefer this hacky garbage since it gives us even more impetus to get rid of syslog4j altogether

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Presumably the same logic also applies to the kbase jars?

Copy link
Member Author

@MrCreosote MrCreosote Feb 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so - we can get rid of syslog4j because we don't want the services logging to syslog anymore anyway. We still need the code in the kbase jars like common / auth

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have thought about trying to get GHA to build jars though, I think they have a maven set up

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I looked into it when I was doing the workspace conversion. It would certainly be neater than having a repo of jars...

*
* This generated file contains a sample Java application project to get you started.
* For more details take a look at the 'Building Java & JVM projects' chapter in the Gradle
* User Manual available at https://docs.gradle.org/7.4.2/userguide/building_java_projects.html

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if all this blurb is really needed...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nuked locally, will show up in a future PR

@Xiangs18
Copy link
Collaborator

Xiangs18 commented Feb 14, 2024

@MrCreosote
Do you think we are ready to remove .classpath as well?

COPY templates /tmp/auth2/templates/
COPY war /tmp/auth2/war/
# for the git commit
COPY .git /tmp/auth2/.git/
Copy link
Collaborator

@Xiangs18 Xiangs18 Feb 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the purpose of moving .git inside the container? To track/verify version?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This step needs access to git: https://github.com/kbase/auth2/pull/419/files#diff-49a96e7eea8a94af862798a45174e6ac43eb4f8b4bd40759b5da63ba31ec3ef7R23

It doesn't factor in the final container size due to the 2 stage build

@MrCreosote
Copy link
Member Author

Do you think we are ready to remove .classpath as well?

It's removed in the next commit after I get Eclipse builds working (with a minor annoyance, but working)

@Xiangs18
Copy link
Collaborator

Xiangs18 commented Feb 14, 2024

@MrCreosote
I am a little bit confused about 3 tasks: generateTemplateFileList, fatTestJar, and generateManageAuthScript. Could you please explain more why we need each of them?

@MrCreosote
Copy link
Member Author

I am a little bit confused about 3 tasks: generateTemplateFileList, fatTestJar, and generateManageAuthScript. Could you please explain more why we need each of them?

Easy one first: generateManageAuthScript generates this: https://github.com/kbase/auth2/blob/develop/README.md?plain=1#L260

generateTemplateFileList creates a list of all the templates (a manifest) in the templates directory. This is solely to make it easier for the test rig to pull the templates out of the fat test jar, as listing directories inside a jar is unnecessarily difficult.

fatTestJar generates a fat test jar, including all dependencies, the templates, and the templates manifest. The fat jar will replace the current auth jar + the jars repo in workspace and other repos for running an auth2 server in their test rigs. The fat jar is completely self contained, so the jars repo is no longer needed

@Xiangs18
Copy link
Collaborator

Xiangs18 commented Feb 14, 2024

@MrCreosote
And where will this fat jar locate in the repo? I cannot find it anywhere after running fatTestJar task.

@MrCreosote
Copy link
Member Author

And where will this fat jar locate in the repo? I cannot find it anywhere after running fatTestJar task.

It's in build/libs

Copy link
Collaborator

@Xiangs18 Xiangs18 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@MrCreosote MrCreosote merged commit 37bff04 into kbase:develop Feb 14, 2024
9 checks passed
@MrCreosote MrCreosote deleted the dev-gradle branch February 14, 2024 02:30
@MrCreosote MrCreosote changed the title Switch from Ant -> Gradle SECURITY-3: Switch from Ant -> Gradle Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants