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

Feature/hg hooks over tcp #1416

Merged
merged 31 commits into from
Nov 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
2331766
Implement mercurial hooks over sockets
sdorra Nov 6, 2020
d518af4
Refactor nearly the whole scm-hg-plugin for new hook implementation
sdorra Nov 7, 2020
d86b2f7
Disable xsrf for mercurial hook tokens
sdorra Nov 8, 2020
36aa059
Disable shiro session storage
sdorra Nov 8, 2020
e774c77
Rename mercurial hooks to match python coding specs
sdorra Nov 8, 2020
5270195
Improve logging for mercurial hooks
sdorra Nov 10, 2020
5118294
Fix multiple accessor threads
sdorra Nov 10, 2020
e038eeb
Improve connection handling of mercurial hook python client
sdorra Nov 10, 2020
70969b5
Update changelog
sdorra Nov 10, 2020
8b4f92f
Remove version script because it is not longer required
sdorra Nov 10, 2020
3fe678e
Remove disableHookSSLValidation field from mercurial settings form
sdorra Nov 10, 2020
84aa8b4
Update pull request link
sdorra Nov 10, 2020
58a0c51
Merge with develop branch
sdorra Nov 18, 2020
c2df6d2
Update storybook components to be compatible with jest 26
sdorra Nov 18, 2020
5311cd5
Fix test for jest 26
sdorra Nov 18, 2020
b6c5a25
Fixed missing messages on exceptions during hook
sdorra Nov 19, 2020
982743e
Fix review findings
sdorra Nov 19, 2020
29faa5e
Fix review findings
sdorra Nov 19, 2020
1311061
Pass transaction id from request to mercurial hooks
sdorra Nov 19, 2020
0b96e7d
Merge branch 'develop' into feature/hg_hooks_over_tcp
eheimbuch Nov 19, 2020
0841a0a
Merge branch 'feature/hg_hooks_over_tcp' of github.com:scm-manager/sc…
sdorra Nov 19, 2020
959dfb8
Fix compiler error
sdorra Nov 19, 2020
33e7a13
Merge branch 'develop' into feature/hg_hooks_over_tcp
pfeuffer Nov 20, 2020
73b2c4a
Do not expose internal exception messages
sdorra Nov 21, 2020
c0ae910
Implement more robust socket hook protocol
sdorra Nov 22, 2020
7357d83
Use DataInputStream and DataOutputStream instead of manual reading an…
sdorra Nov 27, 2020
3e19f28
Do not use socket.MSG_WAITALL
sdorra Nov 27, 2020
8ee8c8b
Merge branch 'develop' into feature/hg_hooks_over_tcp
sdorra Nov 27, 2020
136cdbb
Fix broken HgVersionCommand
sdorra Nov 27, 2020
52f26ab
Merge with develop branch
sdorra Nov 27, 2020
d732100
Fix typo
pfeuffer Nov 27, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased

### Added
- Add tooltips to short links on repository overview ([#1441](https://github.com/scm-manager/scm-manager/pull/1441))
- Show the date of the last commit for branches in the frontend ([#1439](https://github.com/scm-manager/scm-manager/pull/1439))
- Unify and add description to key view across user settings ([#1440](https://github.com/scm-manager/scm-manager/pull/1440))

### Changed
- Send mercurial hook callbacks over separate tcp socket instead of http ([#1416](https://github.com/scm-manager/scm-manager/pull/1416))

### Fixed
- Language detection of files with interpreter parameters e.g.: `#!/usr/bin/make -f` ([#1450](https://github.com/scm-manager/scm-manager/issues/1450))

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@
<!-- xml -->

<dependency>
<groupId>jakarta.xml.bind</groupId>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>${jaxb.version}</version>
</dependency>
Expand Down
6 changes: 6 additions & 0 deletions scm-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,12 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<scope>test</scope>
</dependency>

</dependencies>

<build>
Expand Down
71 changes: 71 additions & 0 deletions scm-core/src/main/java/sonia/scm/TransactionId.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* MIT License
*
* Copyright (c) 2020-present Cloudogu GmbH and Contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package sonia.scm;

import com.google.common.annotations.VisibleForTesting;
import org.slf4j.MDC;

import java.util.Optional;

/**
* Id of the current transaction.
* The transaction id is mainly used for logging and debugging.
*
* @since 2.10.0
*/
public final class TransactionId {

@VisibleForTesting
public static final String KEY = "transaction_id";

private TransactionId() {
}

/**
* Binds the given transaction id to the current thread.
*
* @param transactionId transaction id
*/
public static void set(String transactionId) {
MDC.put(KEY, transactionId);
}

/**
* Returns an optional transaction id.
* If there is no transaction id bound to the thread, the method will return an empty optional.
*
* @return optional transaction id
*/
public static Optional<String> get() {
return Optional.ofNullable(MDC.get(KEY));
}

/**
* Removes a bound transaction id from the current thread.
*/
public static void clear() {
MDC.remove(KEY);
}
}
42 changes: 42 additions & 0 deletions scm-core/src/test/java/sonia/scm/TransactionIdTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* MIT License
*
* Copyright (c) 2020-present Cloudogu GmbH and Contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package sonia.scm;

import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;

class TransactionIdTest {

@Test
void shouldSetGetAndClear() {
TransactionId.set("42");

assertThat(TransactionId.get()).contains("42");
TransactionId.clear();
assertThat(TransactionId.get()).isEmpty();
}

}
14 changes: 14 additions & 0 deletions scm-plugins/scm-hg-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,23 @@
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-nop</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<scope>test</scope>
</dependency>

</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@
import lombok.NoArgsConstructor;
import lombok.Setter;

@NoArgsConstructor
@Getter
@Setter
@NoArgsConstructor
@SuppressWarnings("java:S2160") // we don't need equals for dto
public class HgConfigDto extends HalRepresentation implements UpdateHgConfigDto {


private boolean disabled;

private String encoding;
Expand All @@ -44,7 +46,6 @@ public class HgConfigDto extends HalRepresentation implements UpdateHgConfigDto
private boolean useOptimizedBytecode;
private boolean showRevisionInId;
private boolean enableHttpPostArgs;
private boolean disableHookSSLValidation;

@Override
@SuppressWarnings("squid:S1185") // We want to have this method available in this package
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,5 @@ interface UpdateHgConfigDto {

boolean isShowRevisionInId();

boolean isDisableHookSSLValidation();

boolean isEnableHttpPostArgs();
}