Skip to content

Commit b265cfd

Browse files
authored
merge (#1)
* Check whether filename is a child of the current file (Fixes hierynomus#341) * Fixed codacy * Updated README release notes * Removed oraclejdk7 as that is no longer supported on trusty, added openjdk * Added gradle caching to travis config * Removed use of DataTypeConverter as that is no longer in default JDK9 * Removed build of broken openJDK7 in favour of using animal-sniffer to detect java 1.6 compatibility * Improved test stability * Correctly determine KeyType for ECDSA public key (Fixes hierynomus#356) * fixed build * Fixed Java9 build? * Disambiguated signature initialization * Removed deprecated method * Organised imports * Added 'out/' to gitignore * Added support for new-style fingerprints (hierynomus#365) * Added support for new-style fingerprints * Fixed codacy warnings * Fix decoding signature bytes (Fixes hierynomus#355, hierynomus#354) (hierynomus#361) * Fix for signature verify in DSA * Cleaned up signature verification * Fixed import * Ignored erroneous pmd warnings * Updated JavaDoc * Extracted ASN.1/DER encoding to method (hierynomus#368) * Update net.i2p.crypto:eddsa to 0.2.0 (hierynomus#372) * Update net.i2p.crypto:eddsa to 0.2.0 * Update net.i2p.crypto.eddsa to 0.2.0 * Update net.i2p.crypto.eddsa to 0.2.0 * Update net.i2p.crypto.eddsa to 0.2.0 * Log security provider registration failures (hierynomus#374) * Migrate remaining block ciphers * Updated README for v0.23.0 release * Using new release plugin * Updated build plugins * Fix escaping in WildcardHostMatcher (hierynomus#382) * Escape '[' and ']' in WildcardHostMatcher * Anchoring regex to match entire string (Fixes hierynomus#381) * Updated builds to include CodeCov * - Experimenting with travis * - fix ip for online testing * - account for different working dir * - yaml-yaml * - double before_install * - still -d * - try common format * - Fixed server keys - Use sshj branding * - grr, ip * - minor improvements * - eh? * - switch username back * - orly? * - desperation * - One more time * Upgraded gradle to cope with java9 * Separated out integration tests * Fixed length bug in putString (Fixes hierynomus#187) * Removed docker from travis yml as it is included in gradle build now * Added integration test to travis * Update AndroidConfig (hierynomus#389) * Add EdDSA signature for AndroidConfig. * Initialize KeyExchange- and FileKeyProviderFactories with registered "bouncyCastle" (in fact, SpongyCastle is registered). See hierynomus#308 for discussion. * Added integration test for append scenario (Fixes hierynomus#390) * Fixed headers
1 parent 3d07028 commit b265cfd

File tree

75 files changed

+1362
-473
lines changed

Some content is hidden

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

75 files changed

+1362
-473
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
.settings/
1111

1212
# Output dirs
13+
out/
1314
target/
1415
classes/
1516
build/

.travis.yml

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,30 @@
11
language: java
2-
sudo: false
2+
dist: trusty
3+
sudo: required
4+
5+
services:
6+
- docker
7+
38
jdk:
4-
- oraclejdk7
59
- oraclejdk8
10+
- openjdk8
11+
- oraclejdk9
12+
13+
before_cache:
14+
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
15+
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
16+
17+
cache:
18+
directories:
19+
- $HOME/.gradle/caches/
20+
- $HOME/.gradle/wrapper/
21+
22+
before_install:
23+
- pip install --user codecov
24+
25+
script:
26+
- ./gradlew check
27+
- ./gradlew integrationTest
28+
29+
after_success:
30+
- codecov

README.adoc

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
= sshj - SSHv2 library for Java
22
Jeroen van Erp
33
:sshj_groupid: com.hierynomus
4-
:sshj_version: 0.21.1
4+
:sshj_version: 0.23.0
55
:source-highlighter: pygments
66

7+
image:https://api.bintray.com/packages/hierynomus/maven/sshj/images/download.svg[link="https://bintray.com/hierynomus/maven/sshj/_latestVersion"]
78
image:https://travis-ci.org/hierynomus/sshj.svg?branch=master[link="https://travis-ci.org/hierynomus/sshj"]
89
image:https://api.codacy.com/project/badge/Grade/14a0a316bb9149739b5ea26dbfa8da8a["Codacy code quality", link="https://www.codacy.com/app/jeroen_2/sshj?utm_source=github.com&utm_medium=referral&utm_content=hierynomus/sshj&utm_campaign=Badge_Grade"]
10+
image:https://codecov.io/gh/hierynomus/sshj/branch/master/graph/badge.svg["codecov", link="https://codecov.io/gh/hierynomus/sshj"]
11+
image:http://www.javadoc.io/badge/com.hierynomus/sshj.svg?color=blue["JavaDocs", link="http://www.javadoc.io/doc/com.hierynomus/sshj"]
912
image:https://maven-badges.herokuapp.com/maven-central/com.hierynomus/sshj/badge.svg["Maven Central",link="https://maven-badges.herokuapp.com/maven-central/com.hierynomus/sshj"]
1013
image:https://javadoc-emblem.rhcloud.com/doc/com.hierynomus/sshj/badge.svg["Javadoc",link="http://www.javadoc.io/doc/com.hierynomus/sshj"]
1114

@@ -75,7 +78,7 @@ key exchange::
7578
`diffie-hellman-group16-sha256`, `[email protected]`, `[email protected]`, `[email protected]`
7679

7780
signatures::
78-
`ssh-rsa`, `ssh-dss`, `ecdsa-sha2-nistp256`, `ssh-ed25519`
81+
`ssh-rsa`, `ssh-dss`, `ecdsa-sha2-nistp256`, `ecdsa-sha2-nistp384`, `ecdsa-sha2-nistp521`, `ssh-ed25519`
7982

8083
mac::
8184
`hmac-md5`, `hmac-md5-96`, `hmac-sha1`, `hmac-sha1-96`, `hmac-sha2-256`, `hmac-sha2-512`
@@ -104,7 +107,16 @@ Google Group: http://groups.google.com/group/sshj-users
104107
Fork away!
105108

106109
== Release history
107-
SSHJ 0.22.0 (2017-??-??)::
110+
SSHJ 0.23.0 (2017-10-13)::
111+
* Merged https://github.com/hierynomus/sshj/pulls/372[#372]: Upgrade to 'net.i2p.crypto:eddsa:0.2.0'
112+
* Fixed https://github.com/hierynomus/sshj/issues/355[#355] and https://github.com/hierynomus/sshj/issues/354[#354]: Correctly decode signature bytes
113+
* Fixed https://github.com/hierynomus/sshj/issues/365[#365]: Added support for new-style OpenSSH fingerprints of server keys
114+
* Fixed https://github.com/hierynomus/sshj/issues/356[#356]: Fixed key type detection for ECDSA public keys
115+
* Made SSHJ Java9 compatible
116+
SSHJ 0.22.0 (2017-08-24)::
117+
* Fixed https://github.com/hierynomus/sshj/pulls/341[#341]: Fixed path walking during recursive copy
118+
* Merged https://github.com/hierynomus/sshj/pulls/338[#338]: Added ConsolePasswordFinder to read password from stdin
119+
* Merged https://github.com/hierynomus/sshj/pulls/336[#336]: Added support for ecdsa-sha2-nistp384 and ecdsa-sha2-nistp521 signatures
108120
* Fixed https://github.com/hierynomus/sshj/issues/331[#331]: Added support for wildcards in known_hosts file
109121
SSHJ 0.21.1 (2017-04-25)::
110122
* Merged https://github.com/hierynomus/sshj/pulls/322[#322]: Fix regression from 40f956b (invalid length parameter on outputstream)

build.gradle

Lines changed: 85 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,54 @@
11
import java.text.SimpleDateFormat
2+
import com.bmuschko.gradle.docker.tasks.container.*
3+
import com.bmuschko.gradle.docker.tasks.image.*
24

35
plugins {
46
id "java"
57
id "groovy"
8+
id "jacoco"
69
id "osgi"
710
id "maven-publish"
8-
id "org.ajoberstar.release-opinion" version "1.4.2"
11+
id "com.bmuschko.docker-remote-api" version "3.2.1"
12+
id 'pl.allegro.tech.build.axion-release' version '1.8.1'
913
id "com.github.hierynomus.license" version "0.12.1"
1014
id "com.jfrog.bintray" version "1.7"
11-
id 'ru.vyarus.pom' version '1.0.3'
15+
id 'ru.vyarus.java-lib' version '1.0.5'
16+
// id 'ru.vyarus.pom' version '1.0.3'
1217
id 'ru.vyarus.github-info' version '1.1.0'
18+
id 'ru.vyarus.animalsniffer' version '1.4.2'
1319
}
1420

1521
group = "com.hierynomus"
22+
1623
defaultTasks "build"
1724

1825
repositories {
1926
mavenCentral()
27+
maven {
28+
url "https://dl.bintray.com/mockito/maven/"
29+
}
2030
}
2131

2232
sourceCompatibility = 1.6
2333
targetCompatibility = 1.6
2434

2535
configurations.compile.transitive = false
2636

27-
def bouncycastleVersion = "1.56"
37+
def bouncycastleVersion = "1.57"
2838

2939
dependencies {
40+
signature 'org.codehaus.mojo.signature:java16:1.1@signature'
41+
3042
compile "org.slf4j:slf4j-api:1.7.7"
3143
compile "org.bouncycastle:bcprov-jdk15on:$bouncycastleVersion"
3244
compile "org.bouncycastle:bcpkix-jdk15on:$bouncycastleVersion"
3345
compile "com.jcraft:jzlib:1.1.3"
3446

35-
compile "net.i2p.crypto:eddsa:0.1.0"
47+
compile "net.i2p.crypto:eddsa:0.2.0"
3648

3749
testCompile "junit:junit:4.11"
3850
testCompile 'org.spockframework:spock-core:1.0-groovy-2.4'
39-
testCompile "org.mockito:mockito-core:2.8.47"
51+
testCompile "org.mockito:mockito-core:2.9.2"
4052
testCompile "org.apache.sshd:sshd-core:1.2.0"
4153
testRuntime "ch.qos.logback:logback-classic:1.1.2"
4254
testCompile 'org.glassfish.grizzly:grizzly-http-server:2.3.17'
@@ -53,14 +65,19 @@ license {
5365
excludes(['**/djb/Curve25519.java', '**/sshj/common/Base64.java'])
5466
}
5567

56-
if (project.file('.git').isDirectory()) {
57-
release {
58-
grgit = org.ajoberstar.grgit.Grgit.open(project.projectDir)
68+
scmVersion {
69+
tag {
70+
prefix = 'v'
71+
versionSeparator = ''
72+
}
73+
hooks {
74+
pre 'fileUpdate', [file: 'README.adoc', pattern: { v, c -> /:sshj_version: .*/}, replacement: { v, c -> ":sshj_version: $v" }]
75+
pre 'commit'
5976
}
60-
} else {
61-
version = "0.0.0-no.git"
6277
}
6378

79+
project.version = scmVersion.version
80+
6481
// This disables the pedantic doclint feature of JDK8
6582
if (JavaVersion.current().isJava8Compatible()) {
6683
tasks.withType(Javadoc) {
@@ -78,7 +95,6 @@ task writeSshjVersionProperties {
7895
}
7996

8097
jar.dependsOn writeSshjVersionProperties
81-
8298
jar {
8399
manifest {
84100
// please see http://bnd.bndtools.org/chapters/390-wrapping.html
@@ -99,14 +115,7 @@ jar {
99115
}
100116
}
101117

102-
task javadocJar(type: Jar) {
103-
classifier = 'javadoc'
104-
from javadoc
105-
}
106-
107-
task sourcesJar(type: Jar) {
108-
classifier = 'sources'
109-
from sourceSets.main.allSource
118+
sourcesJar {
110119
manifest {
111120
attributes(
112121
// Add the needed OSGI attributes
@@ -119,6 +128,27 @@ task sourcesJar(type: Jar) {
119128
}
120129
}
121130

131+
configurations {
132+
integrationTestCompile.extendsFrom testCompile
133+
integrationTestRuntime.extendsFrom testRuntime
134+
}
135+
136+
sourceSets {
137+
integrationTest {
138+
groovy {
139+
compileClasspath += sourceSets.main.output + sourceSets.test.output
140+
runtimeClasspath += sourceSets.main.output + sourceSets.test.output
141+
srcDir file('src/itest/groovy')
142+
}
143+
resources.srcDir file('src/itest/resources')
144+
}
145+
}
146+
147+
task integrationTest(type: Test) {
148+
testClassesDirs = sourceSets.integrationTest.output.classesDirs
149+
classpath = sourceSets.integrationTest.runtimeClasspath
150+
}
151+
122152
tasks.withType(Test) {
123153
testLogging {
124154
exceptionFormat = 'full'
@@ -185,21 +215,12 @@ pom {
185215
}
186216
}
187217

188-
publishing.publications {
189-
Sshj(MavenPublication) {
190-
from components.java
191-
artifact sourcesJar
192-
artifact javadocJar
193-
}
194-
}
195-
196-
197218
if (project.hasProperty("bintrayUsername") && project.hasProperty("bintrayApiKey")) {
198219
bintray {
199220
user = project.property("bintrayUsername")
200221
key = project.property("bintrayApiKey")
201222
publish = true
202-
publications = ["Sshj"]
223+
publications = ["maven"]
203224
pkg {
204225
repo = "maven"
205226
name = project.name
@@ -226,4 +247,38 @@ if (project.hasProperty("bintrayUsername") && project.hasProperty("bintrayApiKey
226247
}
227248
}
228249

229-
project.tasks.release.dependsOn([project.tasks.build, project.tasks.bintrayUpload])
250+
jacocoTestReport {
251+
reports {
252+
xml.enabled true
253+
html.enabled true
254+
}
255+
}
256+
257+
258+
task buildItestImage(type: DockerBuildImage) {
259+
inputDir = file('src/itest/docker-image')
260+
tag = 'sshj/sshd-itest'
261+
}
262+
263+
task createItestContainer(type: DockerCreateContainer) {
264+
dependsOn buildItestImage
265+
targetImageId { buildItestImage.getImageId() }
266+
portBindings = ['2222:22']
267+
}
268+
269+
task startItestContainer(type: DockerStartContainer) {
270+
dependsOn createItestContainer
271+
targetContainerId { createItestContainer.getContainerId() }
272+
}
273+
274+
task stopItestContainer(type: DockerStopContainer) {
275+
targetContainerId { createItestContainer.getContainerId() }
276+
}
277+
278+
project.tasks.integrationTest.dependsOn(startItestContainer)
279+
project.tasks.integrationTest.finalizedBy(stopItestContainer)
280+
281+
project.tasks.release.dependsOn([project.tasks.integrationTest, project.tasks.build])
282+
project.tasks.release.finalizedBy(project.tasks.bintrayUpload)
283+
project.tasks.jacocoTestReport.dependsOn(project.tasks.test)
284+
project.tasks.check.dependsOn(project.tasks.jacocoTestReport)

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.0-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.3-all.zip

src/itest/docker-image/Dockerfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM sickp/alpine-sshd:7.5
2+
3+
ADD id_rsa.pub /home/sshj/.ssh/authorized_keys
4+
5+
ADD test-container/ssh_host_ecdsa_key /etc/ssh/ssh_host_ecdsa_key
6+
ADD test-container/ssh_host_ecdsa_key.pub /etc/ssh/ssh_host_ecdsa_key.pub
7+
8+
RUN \
9+
echo "root:smile" | chpasswd && \
10+
adduser -D -s /bin/ash sshj && \
11+
passwd -u sshj && \
12+
chmod 600 /home/sshj/.ssh/authorized_keys && \
13+
chmod 600 /etc/ssh/ssh_host_ecdsa_key && \
14+
chmod 644 /etc/ssh/ssh_host_ecdsa_key.pub && \
15+
chown -R sshj:sshj /home/sshj
16+

src/itest/docker-image/id_rsa.pub

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAoZ9l6Tkm2aL1tSBy2yw4xU5s8BE9MfqS/4J7DzvsYJxF6oQmTIjmStuhH/CT7UjuDtKXdXZUsIhKtafiizxGO8kHSzKDeitpth2RSr8ddMzZKyD6RNs7MfsgjA3UTtrrSrCXEY6O43S2cnuJrWzkPxtwxaQ3zOvDbS2tiulzyq0VzYmuhA/a4CyuQtJBuu+P2oqmu6pU/VB6IzONpvBvYbNPsH1WDmP7zko5wHPihXPCliztspKxS4DRtOZ7BGXyvg44UmIy0Kf4jOkaBV/eCCA4qH7ZHz71/5ceMOpszPcNOEmLGGYhwI+P3OuGMpkrSAv1f8IY6R8spZNncP6UaQ== no-passphrase
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
-----BEGIN EC PRIVATE KEY-----
2+
MHcCAQEEIOpOBFjqe0hjK/hs4WZ3dZqnzanq1L3/JbvV1TCkbe4ToAoGCCqGSM49
3+
AwEHoUQDQgAEVzkrS7Yj0nXML7A3mE08YDthfBR/ZbyYJDIq1vTzcqs6KTaCT529
4+
swNXWLHO+mbHviZcRiI57ULXHZ1emom/Jw==
5+
-----END EC PRIVATE KEY-----
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBFc5K0u2I9J1zC+wN5hNPGA7YXwUf2W8mCQyKtb083KrOik2gk+dvbMDV1ixzvpmx74mXEYiOe1C1x2dXpqJvyc= root@404b27be2bf4
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright (C)2009 - SSHJ Contributors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.hierynomus.sshj
17+
18+
import net.schmizz.sshj.DefaultConfig
19+
import net.schmizz.sshj.SSHClient
20+
import net.schmizz.sshj.transport.verification.PromiscuousVerifier
21+
import spock.lang.Specification
22+
23+
class IntegrationBaseSpec extends Specification {
24+
protected static final int DOCKER_PORT = 2222;
25+
protected static final String USERNAME = "sshj";
26+
protected final static String SERVER_IP = System.getProperty("serverIP", "127.0.0.1");
27+
28+
protected static SSHClient getConnectedClient() throws IOException {
29+
SSHClient sshClient = new SSHClient(new DefaultConfig());
30+
sshClient.addHostKeyVerifier(new PromiscuousVerifier());
31+
sshClient.connect(SERVER_IP, DOCKER_PORT);
32+
33+
return sshClient;
34+
}
35+
36+
}

0 commit comments

Comments
 (0)