Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
33 changes: 26 additions & 7 deletions cs/src/Contracts/TunnelConstraints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ public static class TunnelConstraints
/// <summary>
/// Max length of V2 tunnelId.
/// </summary>
public const int NewTunnelIdMaxLength = 60;
/// <remarks>
/// Limited to 49 characters to ensure tunnel URIs with ports and inspection suffixes
/// (-&lt;port&gt;-inspect) remain within the DNS label limit of 63 characters.
/// </remarks>
public const int NewTunnelIdMaxLength = 49;

/// <summary>
/// Length of a tunnel alias.
Expand All @@ -59,8 +63,18 @@ public static class TunnelConstraints
/// <summary>
/// Max length of tunnel name.
/// </summary>
/// <remarks>
/// Limited to 49 characters to ensure tunnel URIs with ports and inspection suffixes
/// (-&lt;port&gt;-inspect) remain within the DNS label limit of 63 characters.
/// </remarks>
/// <seealso cref="Tunnel.Name"/>
public const int TunnelNameMaxLength = 60;
public const int TunnelNameMaxLength = 49;

/// <summary>
/// Max length of SSH username.
/// </summary>
/// <seealso cref="TunnelPort.SshUser"/>
public const int SshUserMaxLength = 60;

/// <summary>
/// Max length of tunnel or port description.
Expand Down Expand Up @@ -241,11 +255,12 @@ public static class TunnelConstraints
/// Regular expression that can match or validate tunnel ID strings.
/// </summary>
/// <remarks>
/// Tunnel IDs are fixed-length and have a limited character set of
/// numbers and lowercase letters (minus vowels and y).
/// Tunnel IDs have a limited character set of numbers and lowercase letters.
/// Limited to 49 characters to ensure tunnel URIs with ports and inspection suffixes
/// remain within the DNS label limit of 63 characters.
/// </remarks>
/// <seealso cref="Tunnel.TunnelId"/>
public const string NewTunnelIdPattern = "[a-z0-9][a-z0-9-]{1,58}[a-z0-9]";
public const string NewTunnelIdPattern = "[a-z0-9][a-z0-9-]{1,47}[a-z0-9]";

/// <summary>
/// Regular expression that can match or validate tunnel ID strings.
Expand All @@ -270,9 +285,11 @@ public static class TunnelConstraints
/// <remarks>
/// Tunnel Aliases are fixed-length and have a limited character set of
/// numbers and lowercase letters (minus vowels and y).
/// Limited to 49 characters to ensure tunnel URIs with ports and inspection suffixes
/// remain within the DNS label limit of 63 characters.
/// </remarks>
/// <seealso cref="Tunnel.TunnelId"/>
public const string TunnelAliasPattern = "[" + TunnelAliasChars + "]{3,60}";
public const string TunnelAliasPattern = "[" + TunnelAliasChars + "]{3,49}";

/// <summary>
/// Regular expression that can match or validate tunnel alias strings.
Expand All @@ -290,9 +307,11 @@ public static class TunnelConstraints
/// <remarks>
/// Tunnel names are alphanumeric and may contain hyphens. The pattern also
/// allows an empty string because tunnels may be unnamed.
/// Limited to 49 characters to ensure tunnel URIs with ports and inspection suffixes
/// remain within the DNS label limit of 63 characters.
/// </remarks>
/// <seealso cref="Tunnel.Name"/>
public const string TunnelNamePattern = "([a-z0-9][a-z0-9-]{1,58}[a-z0-9])|(^$)";
public const string TunnelNamePattern = "([a-z0-9][a-z0-9-]{1,47}[a-z0-9])|(^$)";

/// <summary>
/// Regular expression that can match or validate tunnel names.
Expand Down
2 changes: 1 addition & 1 deletion cs/src/Contracts/TunnelPort.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public TunnelPort()
/// Should be provided if the <see cref="TunnelProtocol"/> is Ssh.
/// </remarks>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
[StringLength(TunnelNameMaxLength)]
[StringLength(SshUserMaxLength)]
public string? SshUser { get; set; }

/// <summary>
Expand Down
6 changes: 4 additions & 2 deletions cs/test/TunnelsSDK.Test/TunnelConstraintsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,17 @@ public void IsValidTunnelId_NotValid(string tunnelId)
[InlineData("test")]
[InlineData("aaa")]
[InlineData("bcd-ghjk")]
[InlineData("jfullerton44-name-with-special-char--jrw9q5vrfjpwx")]
[InlineData("012345678901234567890123456789012345678901234567890123456789")]
[InlineData("username-name-with-special-char--jrw9q5vrfjpwx")]
[InlineData("0123456789012345678901234567890123456789012345678")]
public void IsValidTunnelName_Valid(string tunnelName)
{
Assert.True(IsValidTunnelName(tunnelName));
}

[Theory]
[InlineData("a")]
[InlineData("username2345-name-with-special-char--jrw9q5vrfjpwx")]
[InlineData("012345678901234567890123456789012345678901234567890123456789")]
[InlineData("0123456789012345678901234567890123456789012345678901234567890")]
[InlineData("89bcdfgh")]
[InlineData("stvwxzzz")]
Expand Down
31 changes: 22 additions & 9 deletions go/tunnels/tunnel_constraints.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ const (
TunnelConstraintsNewTunnelIDMinLength = 3

// Max length of V2 tunnelId.
TunnelConstraintsNewTunnelIDMaxLength = 60
//
// Limited to 49 characters to ensure tunnel URIs with ports and inspection suffixes
// (-&lt;port&gt;-inspect) remain within the DNS label limit of 63 characters.
TunnelConstraintsNewTunnelIDMaxLength = 49

// Length of a tunnel alias.
TunnelConstraintsTunnelAliasLength = 8
Expand All @@ -32,7 +35,13 @@ const (
TunnelConstraintsTunnelNameMinLength = 3

// Max length of tunnel name.
TunnelConstraintsTunnelNameMaxLength = 60
//
// Limited to 49 characters to ensure tunnel URIs with ports and inspection suffixes
// (-&lt;port&gt;-inspect) remain within the DNS label limit of 63 characters.
TunnelConstraintsTunnelNameMaxLength = 49

// Max length of SSH username.
TunnelConstraintsSshUserMaxLength = 60

// Max length of tunnel or port description.
TunnelConstraintsDescriptionMaxLength = 400
Expand Down Expand Up @@ -113,9 +122,10 @@ const (

// Regular expression that can match or validate tunnel ID strings.
//
// Tunnel IDs are fixed-length and have a limited character set of numbers and lowercase
// letters (minus vowels and y).
TunnelConstraintsNewTunnelIDPattern = "[a-z0-9][a-z0-9-]{1,58}[a-z0-9]"
// Tunnel IDs have a limited character set of numbers and lowercase letters. Limited to
// 49 characters to ensure tunnel URIs with ports and inspection suffixes remain within
// the DNS label limit of 63 characters.
TunnelConstraintsNewTunnelIDPattern = "[a-z0-9][a-z0-9-]{1,47}[a-z0-9]"

// Characters that are valid in tunnel IDs. Includes numbers and lowercase letters,
// excluding vowels and 'y' (to avoid accidentally generating any random words).
Expand All @@ -124,14 +134,17 @@ const (
// Regular expression that can match or validate tunnel alias strings.
//
// Tunnel Aliases are fixed-length and have a limited character set of numbers and
// lowercase letters (minus vowels and y).
TunnelConstraintsTunnelAliasPattern = "[" + TunnelConstraintsTunnelAliasChars + "]{3,60}"
// lowercase letters (minus vowels and y). Limited to 49 characters to ensure tunnel URIs
// with ports and inspection suffixes remain within the DNS label limit of 63 characters.
TunnelConstraintsTunnelAliasPattern = "[" + TunnelConstraintsTunnelAliasChars + "]{3,49}"

// Regular expression that can match or validate tunnel names.
//
// Tunnel names are alphanumeric and may contain hyphens. The pattern also allows an
// empty string because tunnels may be unnamed.
TunnelConstraintsTunnelNamePattern = "([a-z0-9][a-z0-9-]{1,58}[a-z0-9])|(^$)"
// empty string because tunnels may be unnamed. Limited to 49 characters to ensure tunnel
// URIs with ports and inspection suffixes remain within the DNS label limit of 63
// characters.
TunnelConstraintsTunnelNamePattern = "([a-z0-9][a-z0-9-]{1,47}[a-z0-9])|(^$)"

// Regular expression that can match or validate tunnel or port labels.
TunnelConstraintsLabelPattern = "[\\w-=]{1,50}"
Expand Down
2 changes: 1 addition & 1 deletion go/tunnels/tunnels.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/rodaine/table"
)

const PackageVersion = "0.1.21"
const PackageVersion = "0.1.22"

func (tunnel *Tunnel) requestObject() (*Tunnel, error) {
convertedTunnel := &Tunnel{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,11 @@ public class TunnelConstraints {

/**
* Max length of V2 tunnelId.
*
* Limited to 49 characters to ensure tunnel URIs with ports and inspection suffixes
* (-&lt;port&gt;-inspect) remain within the DNS label limit of 63 characters.
*/
public static final int newTunnelIdMaxLength = 60;
public static final int newTunnelIdMaxLength = 49;

/**
* Length of a tunnel alias.
Expand All @@ -47,8 +50,16 @@ public class TunnelConstraints {

/**
* Max length of tunnel name.
*
* Limited to 49 characters to ensure tunnel URIs with ports and inspection suffixes
* (-&lt;port&gt;-inspect) remain within the DNS label limit of 63 characters.
*/
public static final int tunnelNameMaxLength = 49;

/**
* Max length of SSH username.
*/
public static final int tunnelNameMaxLength = 60;
public static final int sshUserMaxLength = 60;

/**
* Max length of tunnel or port description.
Expand Down Expand Up @@ -197,10 +208,11 @@ public class TunnelConstraints {
/**
* Regular expression that can match or validate tunnel ID strings.
*
* Tunnel IDs are fixed-length and have a limited character set of numbers and
* lowercase letters (minus vowels and y).
* Tunnel IDs have a limited character set of numbers and lowercase letters. Limited
* to 49 characters to ensure tunnel URIs with ports and inspection suffixes remain
* within the DNS label limit of 63 characters.
*/
public static final String newTunnelIdPattern = "[a-z0-9][a-z0-9-]{1,58}[a-z0-9]";
public static final String newTunnelIdPattern = "[a-z0-9][a-z0-9-]{1,47}[a-z0-9]";

/**
* Regular expression that can match or validate tunnel ID strings.
Expand All @@ -220,9 +232,11 @@ public class TunnelConstraints {
* Regular expression that can match or validate tunnel alias strings.
*
* Tunnel Aliases are fixed-length and have a limited character set of numbers and
* lowercase letters (minus vowels and y).
* lowercase letters (minus vowels and y). Limited to 49 characters to ensure tunnel
* URIs with ports and inspection suffixes remain within the DNS label limit of 63
* characters.
*/
public static final String tunnelAliasPattern = "[" + TunnelConstraints.tunnelAliasChars + "]{3,60}";
public static final String tunnelAliasPattern = "[" + TunnelConstraints.tunnelAliasChars + "]{3,49}";

/**
* Regular expression that can match or validate tunnel alias strings.
Expand All @@ -236,9 +250,11 @@ public class TunnelConstraints {
* Regular expression that can match or validate tunnel names.
*
* Tunnel names are alphanumeric and may contain hyphens. The pattern also allows an
* empty string because tunnels may be unnamed.
* empty string because tunnels may be unnamed. Limited to 49 characters to ensure
* tunnel URIs with ports and inspection suffixes remain within the DNS label limit of
* 63 characters.
*/
public static final String tunnelNamePattern = "([a-z0-9][a-z0-9-]{1,58}[a-z0-9])|(^$)";
public static final String tunnelNamePattern = "([a-z0-9][a-z0-9-]{1,47}[a-z0-9])|(^$)";

/**
* Regular expression that can match or validate tunnel names.
Expand Down
30 changes: 21 additions & 9 deletions rs/src/contracts/tunnel_constraints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ pub const OLD_TUNNEL_ID_LENGTH: i32 = 8;
pub const NEW_TUNNEL_ID_MIN_LENGTH: i32 = 3;

// Max length of V2 tunnelId.
pub const NEW_TUNNEL_ID_MAX_LENGTH: i32 = 60;
//
// Limited to 49 characters to ensure tunnel URIs with ports and inspection suffixes
// (-&lt;port&gt;-inspect) remain within the DNS label limit of 63 characters.
pub const NEW_TUNNEL_ID_MAX_LENGTH: i32 = 49;

// Length of a tunnel alias.
pub const TUNNEL_ALIAS_LENGTH: i32 = 8;
Expand All @@ -26,7 +29,13 @@ pub const TUNNEL_ALIAS_LENGTH: i32 = 8;
pub const TUNNEL_NAME_MIN_LENGTH: i32 = 3;

// Max length of tunnel name.
pub const TUNNEL_NAME_MAX_LENGTH: i32 = 60;
//
// Limited to 49 characters to ensure tunnel URIs with ports and inspection suffixes
// (-&lt;port&gt;-inspect) remain within the DNS label limit of 63 characters.
pub const TUNNEL_NAME_MAX_LENGTH: i32 = 49;

// Max length of SSH username.
pub const SSH_USER_MAX_LENGTH: i32 = 60;

// Max length of tunnel or port description.
pub const DESCRIPTION_MAX_LENGTH: i32 = 400;
Expand Down Expand Up @@ -107,9 +116,10 @@ pub const NEW_TUNNEL_ID_CHARS: &str = r#"0123456789abcdefghijklmnopqrstuvwxyz-"#

// Regular expression that can match or validate tunnel ID strings.
//
// Tunnel IDs are fixed-length and have a limited character set of numbers and lowercase
// letters (minus vowels and y).
pub const NEW_TUNNEL_ID_PATTERN: &str = r#"[a-z0-9][a-z0-9-]{1,58}[a-z0-9]"#;
// Tunnel IDs have a limited character set of numbers and lowercase letters. Limited to 49
// characters to ensure tunnel URIs with ports and inspection suffixes remain within the
// DNS label limit of 63 characters.
pub const NEW_TUNNEL_ID_PATTERN: &str = r#"[a-z0-9][a-z0-9-]{1,47}[a-z0-9]"#;

// Characters that are valid in tunnel IDs. Includes numbers and lowercase letters,
// excluding vowels and 'y' (to avoid accidentally generating any random words).
Expand All @@ -118,14 +128,16 @@ pub const TUNNEL_ALIAS_CHARS: &str = r#"0123456789bcdfghjklmnpqrstvwxz"#;
// Regular expression that can match or validate tunnel alias strings.
//
// Tunnel Aliases are fixed-length and have a limited character set of numbers and
// lowercase letters (minus vowels and y).
pub const TUNNEL_ALIAS_PATTERN: &str = r#"[0123456789bcdfghjklmnpqrstvwxz]{3,60}"#;
// lowercase letters (minus vowels and y). Limited to 49 characters to ensure tunnel URIs
// with ports and inspection suffixes remain within the DNS label limit of 63 characters.
pub const TUNNEL_ALIAS_PATTERN: &str = r#"[0123456789bcdfghjklmnpqrstvwxz]{3,49}"#;

// Regular expression that can match or validate tunnel names.
//
// Tunnel names are alphanumeric and may contain hyphens. The pattern also allows an empty
// string because tunnels may be unnamed.
pub const TUNNEL_NAME_PATTERN: &str = r#"([a-z0-9][a-z0-9-]{1,58}[a-z0-9])|(^$)"#;
// string because tunnels may be unnamed. Limited to 49 characters to ensure tunnel URIs
// with ports and inspection suffixes remain within the DNS label limit of 63 characters.
pub const TUNNEL_NAME_PATTERN: &str = r#"([a-z0-9][a-z0-9-]{1,47}[a-z0-9])|(^$)"#;

// Regular expression that can match or validate tunnel or port labels.
pub const LABEL_PATTERN: &str = r#"[\w-=]{1,50}"#;
Expand Down
4 changes: 2 additions & 2 deletions ts/src/connections/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
"buffer": "^5.2.1",
"debug": "^4.1.1",
"vscode-jsonrpc": "^4.0.0",
"@microsoft/dev-tunnels-contracts": "^1.3.8",
"@microsoft/dev-tunnels-management": "^1.3.8",
"@microsoft/dev-tunnels-contracts": "^1.3.9",
"@microsoft/dev-tunnels-management": "^1.3.9",
"uuid": "^3.3.3",
"await-semaphore": "^0.1.3",
"websocket": "^1.0.28",
Expand Down
34 changes: 25 additions & 9 deletions ts/src/contracts/tunnelConstraints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,11 @@ export namespace TunnelConstraints {

/**
* Max length of V2 tunnelId.
*
* Limited to 49 characters to ensure tunnel URIs with ports and inspection suffixes
* (-&lt;port&gt;-inspect) remain within the DNS label limit of 63 characters.
*/
export const newTunnelIdMaxLength: number = 60;
export const newTunnelIdMaxLength: number = 49;

/**
* Length of a tunnel alias.
Expand All @@ -44,8 +47,16 @@ export namespace TunnelConstraints {

/**
* Max length of tunnel name.
*
* Limited to 49 characters to ensure tunnel URIs with ports and inspection suffixes
* (-&lt;port&gt;-inspect) remain within the DNS label limit of 63 characters.
*/
export const tunnelNameMaxLength: number = 49;

/**
* Max length of SSH username.
*/
export const tunnelNameMaxLength: number = 60;
export const sshUserMaxLength: number = 60;

/**
* Max length of tunnel or port description.
Expand Down Expand Up @@ -194,10 +205,11 @@ export namespace TunnelConstraints {
/**
* Regular expression that can match or validate tunnel ID strings.
*
* Tunnel IDs are fixed-length and have a limited character set of numbers and
* lowercase letters (minus vowels and y).
* Tunnel IDs have a limited character set of numbers and lowercase letters. Limited
* to 49 characters to ensure tunnel URIs with ports and inspection suffixes remain
* within the DNS label limit of 63 characters.
*/
export const newTunnelIdPattern: string = '[a-z0-9][a-z0-9-]{1,58}[a-z0-9]';
export const newTunnelIdPattern: string = '[a-z0-9][a-z0-9-]{1,47}[a-z0-9]';

/**
* Regular expression that can match or validate tunnel ID strings.
Expand All @@ -217,9 +229,11 @@ export namespace TunnelConstraints {
* Regular expression that can match or validate tunnel alias strings.
*
* Tunnel Aliases are fixed-length and have a limited character set of numbers and
* lowercase letters (minus vowels and y).
* lowercase letters (minus vowels and y). Limited to 49 characters to ensure tunnel
* URIs with ports and inspection suffixes remain within the DNS label limit of 63
* characters.
*/
export const tunnelAliasPattern: string = '[' + TunnelConstraints.tunnelAliasChars + ']{3,60}';
export const tunnelAliasPattern: string = '[' + TunnelConstraints.tunnelAliasChars + ']{3,49}';

/**
* Regular expression that can match or validate tunnel alias strings.
Expand All @@ -233,9 +247,11 @@ export namespace TunnelConstraints {
* Regular expression that can match or validate tunnel names.
*
* Tunnel names are alphanumeric and may contain hyphens. The pattern also allows an
* empty string because tunnels may be unnamed.
* empty string because tunnels may be unnamed. Limited to 49 characters to ensure
* tunnel URIs with ports and inspection suffixes remain within the DNS label limit of
* 63 characters.
*/
export const tunnelNamePattern: string = '([a-z0-9][a-z0-9-]{1,58}[a-z0-9])|(^$)';
export const tunnelNamePattern: string = '([a-z0-9][a-z0-9-]{1,47}[a-z0-9])|(^$)';

/**
* Regular expression that can match or validate tunnel names.
Expand Down
Loading
Loading